To: ...">

The jquery.prettyPhoto attachment calls the script to display on the page

When I move:

<script src="js/jquery.prettyPhoto.js"></script> 

To:

 <script type="text/javascript"> ... </script> 

Then the script begins to appear on the page with the bold part:

style = "border: none; overflow: hidden; width: 500px; height: 23px;" allowTransparency = "true"> '}, s); var o = this, u = false, a, f, l, c, h, p, d = e (window) .height (), v = e ...

The script contacts this information:

 Class: prettyPhoto Use: Lightbox clone for jQuery Author: Stephane Caron (http://www.no-margin-for-errors.com) Version: 3.1.5 

How to move script from .js file to page correctly ?

+6
source share
3 answers

When the contents of a javascript contains a closing script </script> , it can cause the browser analyzer to misinterpret the script block code.

The code is here:

 <script type="text/javascript"> alert("</script>"); </script> 

Will not work, and the output you see in the browser will be

 "); 

As if the browser read the script block as

 **script start tag ->** <script type="text/javascript"> alert("</script> **<- script end tag** 

Decision

There are two well-known solutions for the <script>...</script> inside the script block:

  • Divide the line into two separate lines and combine them with +

 <script type="text/javascript"> alert("<scr"+"ipt>...</scr"+ "ipt>"); </script> 
  1. Wrap the entire block of script code with a block of comment code:

  <script type="text/javascript"> <!-- alert("<script></script>"); --> </script> 

Please note that in the second example DOES NOT WORK if you only have a closing tag, because the browser will mark this closing line as the tag that should have closed your original <scrip> .

This example will not work:

  <script type="text/javascript"> <!-- alert("</script>"); --> </script> 

In particular, for your code, this is jsfiddle , which fixes it.

+3
source

No mistakes. https://jsfiddle.net/rL9h958e/1/

The script had a lot of = = problems, as well as bad html.

Social_Tools looks suspicious in all cases,

 social_tools:'<div class="twitter"><a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a></div>' + '<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></div>' + '<div class="facebook"> 
+2
source

Is your html4 or html5 page?

 <script type="text/javascript" src="javascript.js"></script> 

html5 you do not need to use type =

 <script src="javascript.js"></script> 
+1
source

All Articles