I am just trying to add some dynamic javascript to the content of my web browser . My scenario is ,I want to display an Ad which is mapped to a zoneID that will be entered by the user from the phone screen. To be more precise I just want to add the following javascript
<script src="http://rq.vserv.mobi/delivery/js.php?zoneid=d03e63db&vr=S-JS-1.0.0"></script> </div>
where zoneid will dynamically vary upon the user input.
I searched a lot for this as I have never worked with JS before ,and I got this article -
http://matthiasshapiro.com/2012/11/26/windows-phone-html-5-app-basics/
There are two ways I tried to implement this First one is I tried to navigate to the hardcoded HTML content including script-
webBrowser.NavigateToString(string.Format("<html><head><meta name=\"viewport\" content=\"width=device-width,height=device-height,user-scalable=no\"><script type=\"text/javascript\" src=\"http://rq.vserv.mobi/delivery/js.php?zoneid={0}&vr=S-JS-1.0.0\"></script></head><body></body></html>",p_zoneID));
The Second one is having a local HTML page ,Loading it on the webbrowser's Loaded event,and then inject a script into it -
webBrowser.InvokeScript("eval",
new string[] { "document.getElementById('dynamicTitle').innerHTML = '" + javascript_tag + "';" });
Both the ways are working in the second case when I get the ad,that ad is clickable as I am getting the whole script mapped with that ad .(I checked it by using the webbrowser's SaveToString() method.)
But the problem is that in the first case the ad that I am getting is not clickable as the script related to that is not there .(In the content of HTML page)(Checked this also using the SaveToString();)
I have tried a lot but unable to find any clue. What should be my approach now to know why that ad is not clickable and why I am not getting the script mapped with it .
I can also post the HTML content in both the cases if suggested. Thanks is advance, please help me to go solve this as I am stuck at this point and need clarification of things .