[RESOLVED] dynamically load/change javascript
I have a piece of javascript form alexa.com.
Code:
<script type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url=codeguru.com'></script>
When I place this tag anywhere in the body (for example somewhere in a table), it works just fine. But the problem is, that I don't know how I can change the url dynamically.
I know which url to show in the page_load, and I tried the next:
Code:
string url = Request.QueryString["url"];
string script = string.Format("<script type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url={0}'></script>", url);
Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", script, false);
This works, but the image produced by the javascript is placed on top of the page.
How can I change this and place the image not on top of the page?
Re: dynamically load/change javascript
After lots of googling I found the solution. Actually it is really simple.
Just use an asp:Literal control and change its text property
Code:
literalAlexa.Text = "<script type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url=codeguru.com'></script>";