Master page and JavaScript problem
I prepared an aspx file that can open a new window with (window.open) command. In the child window, some values send to parent page with (.innerHTML) command and it can close itself . However, after I set a master page to parent page , command can not send any value from new window to parent and it can not close itself.
How master page can affect my javascript commands?
ThanksEDIT: By drachenstern (I do what I can with what I have ... this is what he pasted)
From child code behind:
<br> Page.RegisterStartupScript("CLOSE",
"<...JS...><script type=\"text/javascript\">" +<br>
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +&开发者_开发知识库lt;br>
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\";
<br>
self.close();" +
"<...JS....></script>"
);<br>
Parent side:
<br>
..a ..<br>href="javascript:window.open('SelectTable.aspx','OPEN','toolbar=no,directories=no,status=no,titlebar=no,menubar=no,scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,');"/>SelectSomthng<br>../a..
SECOND EDIT: (again drachenstern) It would appear this is the intention
From child code behind:
Page.RegisterStartupScript("CLOSE",
"<...JS...><script type=\"text/javascript\">" +
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\"; +
self.close();" + "<...JS....></script>");
Parent side:
/* drachenstern: notice I put the carriage returns for legibility, not in the original code*/
<a href="javascript:window.open(
'SelectTable.aspx',
'OPEN',
'toolbar=no,directories=no,status=no,titlebar=no,menubar=no,
scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,'
);"/>SelectSomthng</a>
if you want to get the control of parent page in the child window and using master page for the parent page... then you can use following to get the control of input type or any other type using the TagName
var collection=window.opener.document.body.getElementsByTagName('input')
alert(collection[o].id);
alert(collection[1].id);
alert(collection[2].id);..... ext
you can traverse through the collection to and find the id you want by indexOf()
method and perform whatever things you want.
From child code behind:
Page.RegisterStartupScript("CLOSE",
"<...JS...>" +
"window.opener.document.getElementById('TableID').innerHTML = \"" + RadioNumber + "\";" +
"window.opener.document.getElementById('HiddenTableID').value = \"" + RadioNumber + "\";" +
"self.close();" +
"<...JS....>"
);
Parent side:
..a ..
href="javascript:window.open('SelectTable.aspx','OPEN','toolbar=no,directories=no,status=no,titlebar=no,
menubar=no,scrollbars=no,resizable=no,width=800,height=600,top=0,left=0,');"/>SelectSomthng
../a..
精彩评论