<!--The element of images is the child window. I can get the javascript to work
correctly from the child window, but I need the class of the image clicke
on from the parent page to effect the child window using window.open.-->
<div class="slides">
<img class="item-1 cardone" src="images/cardone.jpg"/>
<img class="item-2 cardtwo" src="images/cardtwo.jpg"/>
<img class="item-3 cardthree" src="images/cardthree.jpg"/>
<img class="item-4 cardfour" src="images/cardfour.jpg"/>
<img class="item-5 cardfive" src="images/cardfive.jpg"/>
</div>
在点击传送的JavaScript从父窗口的子窗口中使用,window.open
$('.icon-search').click(newWindow); //targeting the image
function newWindow(){
var win = window.open('../carousel/index.html'); //child window
var script = document.createElement('script');
var $this = $(this).prev().attr('class'); //class of image to save for child window
//script below pertains to only child window
$("."+newSrc+"").not(this).remove('img');
$(this).insertAfter($('.slides img:nth-child(2)')).addClass('item-3');
$('.slides img:nth-child(1)').removeClass().addClass('item-1');
$('.slides img:nth-child(2)').removeClass().addClass('item-2');
script.src = 'pf-js/projects.js';
win.document.head.appendChild(script);
}
我需要的脚本调试,并在控制台检查时使用window.open,被转移,没有脚本被转移。
试试这个:'win.document.getElementsByTagName( “头”)[0] .appendChild(脚本);' –
@LouysPatriceBessette脚本不工作..我的不正确的底部看win.document.head.appendChild(脚本);从您的体验控制台日志应该显示在头部的新脚本? –