我有一对网友列表,foreach点击几个网址我想要的是
- open a new window (because if it's IFRAME I will get a SAMEORIGIN issue)
- browse url A
- onload complete url A, browse urlB in the same window instance.
列表如下:
<span onclick="browseChain(urlA, urlB)">first Item</span>
<script>
function browseChain(urlA, urlB){
var myPopup = window.open(urlA, 'preview');
myPopup.addEventListener('load', function(){
console.log('url open: '+urlB);
setTimeout("window.open('"+urlB+"', 'preview');", 2000);
}, false);
}
</script>
像上面似乎Js并没有拦截&#34;加载&#34;事件...
答案 0 :(得分:0)
试试这个会起作用:
JSFiddle:https://jsfiddle.net/r1pgvf3z/1/
<span onclick="browseChain('urlA', 'urlB');">first Item</span>
<script>
function browseChain(urlA, urlB){
console.log("rohit");
var myPopup = window.open(urlA, 'preview');
myPopup.addEventListener('load', function(){
console.log('url open: '+urlB);
setTimeout("window.open(urlB, 'preview');", 2000);
}, false);
}
</script>