How to debug the noscript tag
I am making a widget and I wrapped some JavaScript with a noscript tag and now I just get a blank screen and no error messages I can notice.
Here is the example: http://www.comehike.com/outdoors/widget.php?hike_id=108&height=600&width=700
If you paste in the url from the view-source of that page, you will get something happening. But for so开发者_开发百科me reason, this url I linked to shows nothing. Why is that happening?
Thanks!!
There isn't a lot to debug. Just try the page with JS on and with it off. As usual, validating is helpful.
If you have JavaScript turned on, then the <noscript>
element will be ignored and you see nothing. This is expected.
If you have JavaScript turned off, then the <iframe>
will be rendered, and the page inside loaded. That page consists of a heading, a few empty elements, and a lot of JavaScript (which won't run because JS isn't turned on).
You didn't close the <a>
tag.
Before:
<noscript>
<iframe style="width:700px;height:600px" src="http://www.comehike.com/outdoors/hike_widget.php?hike_id=108&height=600&width=700" >
<p>Your browser does not support iframes.</p></iframe>
<p><a href="http://www.comehike.com/">Widget by comehike.com</p>
</noscript>
After:
<noscript>
<iframe style="width:700px;height:600px" src="http://www.comehike.com/outdoors/hike_widget.php?hike_id=108&height=600&width=700" >
<p>Your browser does not support iframes.</p></iframe>
<p><a href="http://www.comehike.com/">Widget by comehike.com</a></p>
</noscript>
Remember, anything inside the <noscript>
tag will only be displayed to browsers that either don't support JavaScript or have it disabled.
JavaScript inside a <noscript>
tag will never be activated - the element will only be rendered if the browser doesn't support the language specified in the <script>
tags (or it's disabled).
To test the noscript tags, you can use an HTML validator to ensure you've placed the <noscript>
tags in valid / legal places in your HTML.
http://validator.w3.org/
Other than that, just view your pages with JavaScript disabled to see the effect.
精彩评论