Several methods of HTML calling JS variables and functions

Source: Internet
Author: User

Quoted http://blog.csdn.net/shenshen123jun/article/details/18078291

<span style= "FONT-SIZE:18PX;" >var restid= 2;//JavaScript Variablesfunction A () {//JavaScript functionswindow.open ("Shownews.aspx?id=" +restid);}</script> var str1,str2 str1= "FDSGDG dsfdsf China"str2= "Wuhan Rtvu"document.write ("Display string 1:" +str1+ "<br>") document.write ("Display String 2:" + str2 + "<br>")  //the document.write () function is important to write so that you can read the JavaScript parameters correctly.<span style= "color: #ff6666;" >//mode One, open a new window, go to the new link</span> document.write ("<a href= ' shownews.aspx?id=" +restid+ "' style= ' text-decoration:none; color:Black; ' t arget= ' _blank ' > target page </a>)   </script><span style= "color: #ff9966;" >//mode Two, use Javascript:location.href, but cannot open link in new window</span> <a href= "javascript:location.href= ' shownews.aspx?id= ' + restid" style= "text-decoration:none;  Color:black; " target= "_blank" > target page </a><span style= "color: #33cc00;" >//way three, use Javascript:open, only in Sogou browser open, in IE, Firefox, 360 browser inside can not open, that means this method is not very good</span> <a href= "Javascript:open (' shownews.aspx?id= ' + restid)" style= "Text-decoration:none;  Color:black; " target= "_blank" > target page </a><span style= "color: #ff6666;" >//mode four uses window.open but the mouse is the arrow instead of the hand type that represents the link,</span> <a onclick= "window.open (' shownews.aspx?id= ' + restid)" style= "Text-decoration:none;  Color:black; " target= "_blank" > target page </a><span style= "color: #009900;" >//mode Five calls the JavaScript function, but the mouse is the arrow instead of the hand type that represents the link,</span><a onclick= "javascript:a ()" style= "Text-decoration:none;  Color:black; " target= "_blank" > target page </a></form></body></span>

Several methods of HTML calling JS variables and functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.