Click to See Complete Forum and Search --> : [RESOLVED] dynamically load/change javascript


dannystommen
March 20th, 2009, 11:10 AM
I have a piece of javascript form alexa.com.


<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:

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?

dannystommen
March 23rd, 2009, 04:48 AM
After lots of googling I found the solution. Actually it is really simple.

Just use an asp:Literal control and change its text property


literalAlexa.Text = "<script type='text/javascript' language='JavaScript' src='http://xslt.alexa.com/site_stats/js/s/a?url=codeguru.com'></script>";