Android Question webview and script?

Discussion in 'Android Questions' started by FJS, Jun 20, 2015.

  1. FJS

    FJS Active Member Licensed User

    Hello everybody,

    I am trying to use the following html code:

    <script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>

    As you can see, the idea is showing ads, and in this case, the ads networking (leadbolt in fact), told me that is necessary to use a webview.

    I tried it, with a webview like this:

    WebView1.LoadHtml("<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>")

    however it has a syntax error... and only the text apears:( in my screan

    Please, any expert could you tell me how white right the information?

    Thank you!
     
    Devan likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Change your code to:
    Code:
    WebView1.LoadHtml($"<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>"$)
     
    Devan likes this.
  3. FJS

    FJS Active Member Licensed User

    you are a great, thank you :):):):):):):)

    By the way, how is possible to change further characteristic of webview?, the image is not in the centre of the rectangule, and the background is white and I need to have it transparent..

    Thank you again

    Best regards
     
  4. warwound

    warwound Expert Licensed User

    Devan and DonManfred like this.
  5. FJS

    FJS Active Member Licensed User

    Thank you for recommendation;)

    However there is another problem, now the ad image is showed perfectly with the Erel's recommendation, but if you press on the ad, a message appears: "webpage not available", so I suppose it is not right yet. Would you know the root case? and how to solve it?:(:(

    Thanks again
     
  6. FJS

    FJS Active Member Licensed User

    I found the solution, and I would like to share it with all of you :):):):):

    WebView1.LoadHtml($"<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>"$)

    Sub WebView1_OverrideUrl (Url As String) As Boolean
    If Url.EqualsIgnoreCase($"<script type="text/javascript" src="http://ad.leadboltads.net/show_app_ad.js?section_id=xxxxxxxxx"></script>"$) Then
    Return False
    Else
    Dim i As Intent
    i.Initialize(i.ACTION_VIEW, Url)
    StartActivity(i)
    Return True
    End If
    End Sub

    With this the ad works perfectly.

    However the ad shows not in the centre of the webview, and I dont know how to do transparent the background of the webview. Please.. anybody knows how to do it?? :(

    Thank you
     
Loading...