SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Jan 9, 2001, 16:18 #1
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
Got a small JavaScript problem. I cannot print out a JavaScript variable the way I would like. For example...
This prints out the variable just fine:
Code:<html> <head> <script language="JavaScript"> var url = "http://www.somesite.com"; </script> </head> <body> <script language="JavaScript">document.write(url);</script> </body> </html>
Code:<html> <head> <script language="JavaScript"> var url = "http://www.somesite.com"; </script> </head> <body> <a href="<script language='JavaScript'>document.write(url);</script>"> </body> </html>
-
Jan 9, 2001, 16:56 #2
- Join Date
- Aug 1999
- Location
- East Lansing, MI USA
- Posts
- 12,937
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Remember JS is processed inline with the HTML.
Here is what you have.
<a href = "<html tag>blah blah</html tag>">Link</a>
Now you see why it doesn't work? You cannot include an HTML like that within the arguement on another HTML tag and hope it'll still get processed. You've been working with PHP too much.
What you may want to try to do is this:
var url = '<a href = "www.blah.com">link</a>'
Chris Beasley - I publish content and ecommerce sites.
Featured Article: Free Comprehensive SEO Guide
My Guide to Building a Successful Website
My Blog|My Webmaster Forums
-
Jan 9, 2001, 17:17 #3
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yeah, I'd thought of doing it that way - was just wondering if I could do it the other way somehow. Still don't totally understand why it wouldn't work, but thank you anyway.
-
Jan 9, 2001, 17:58 #4
- Join Date
- Aug 1999
- Location
- East Lansing, MI USA
- Posts
- 12,937
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Think of it like this.
Code:<a href = "<B>http:/www.blah.com</b>">Bold Link</a>
ChrisChris Beasley - I publish content and ecommerce sites.
Featured Article: Free Comprehensive SEO Guide
My Guide to Building a Successful Website
My Blog|My Webmaster Forums
-
Jan 9, 2001, 19:54 #5
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ah, I see. I understood the HTML within HTML part, but I guess I never thought of JavaScript that way.
Thanks.
Bookmarks