Method for outputting the </script> label in JavaScript, javascriptscript
The '</script>' pop-up in JS will make JS mistakenly think that this is an end label, and an exception occurs.
As shown in the following code:
We use alert in the <script> block to pop up the '</script>' string. The result is mistakenly thought to be the end tag, and VIM has changed color. Running result
Because the string is treated as the end tag, an exception occurs. Obviously this is not the expected result. We only need to slightly process the code.
Use the plus sign to link the string in '</script>'. '</scr' + 'ipt'> 'to check the running result.
The program is normal. The string '</script>' is displayed correctly. In JS, if the string is connected by the plus sign, the plus sign is used to add the numbers.
How to call javaScript scripts in the <a> </a> label
<Html>
<Head>
<Script type = "text/javascript">
Function myf (){
Alert ("I am link 2 ");
}
</Script>
</Head>
<Body>
<A href = "javascript: alert ('I am the link 1')"> link 1 </a>
<A href = "#" onClick = "myf ()"> link 2 </a>
</Body>
</Html>
---------
Both of them are supported. The second type is recommended.
<Script type = "text/javascript"> How do I write code with line breaks?
I know what you mean. The code is divided into multiple sections and cannot be modified ......
This is quite troublesome, because the output is multi-line, and the string between quotation marks cannot be wrapped. So there is a problem and I am sorry that I didn't see it clearly at first.
I provide a solution, which is a little troublesome. For your reference, we will use the table you provided:
1. Put the automatically generated code (TAG) into a <script> tag pair, and eventually it looks like this:
<Script id = "s1" name = "ss">
/* <Table border = "1" width = "100%">
<Tr>
<Td width = "100%"> </td>
</Tr>
</Table> */
</Script>
2. Write in javascript Code as follows:
<Script>
Var s1Str = document. getElementById ("s1"). innerHTML;
Var pos1 = s1Str. indexOf ("/*");
Var pos2 = s1Str. indexOf ("*/");
S1Str = s1Str. substring (pos1 + 2, pos2 );
Document. write (s1Str );
</Script>