In Chapter 2 "proficient in HTML: semantics, standards, and styles", there is a javascript solution for "click to bring up a new window". The Code is as follows:
function popup(){ if(!document.getElementsByTagName || !document.getElementsByTagName("a")) return false; a = document.getElementsByTagName("a");for(i=0;i< a.length;i++) { if(a[i].getAttribute("rel") && a[i].getAttribute("rel") == "external") { a[i].onclick = function() { window.open(this.getAttribute('href')); return false; }; } }}
In the Web document, define the attribute REL of A as external. A new window is displayed to replace target = "_ blank ".
As the code above contains several minor bugs such as variable scope, the Code is not well written. The following is a slight improvement:
/* Popup: add all links containing external in the rel attribute in the document to bring up the function of a new window */function popup () {If (! Document. getelementsbytagname |! Document. getelementsbytagname ('A') return; VaR as = document. getelementsbytagname ('A'); var relatt; For (VAR I = 0; I <. length; I ++) {relatt = as [I]. getattribute ('rel '); If (relatt & relatt = 'external') {as [I]. onclick = function () {window. open (this. href); Return false ;}}}}