|
-
March 20th, 2009, 11:10 AM
#1
[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?
-
March 23rd, 2009, 04:48 AM
#2
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>";
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|