Reputation: 69
Why does Dreamweaver page using .dwt show syntax error for this script line?
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>');
</script>
It shows syntax error only on a page using the template .dwt file. Does not show error in the template - only when applied to a page.
Upvotes: 1
Views: 1035
Reputation:
You are not escaping the first /
character
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"> <\/script>');
</script>
Should be
<script>
window.jQuery || document.write('<script src="js\/jquery.min.js"> <\/script>');
</script>
Although you can use document.createElement('script')
which is less confusing for the parser
if(!window.jQuery) {
var script = document.createElement("script");
script.src = "js/jquery.min.js";
document.body.appendChild(script);
}
Upvotes: 1