Jump to content

Script With in Script


a_krishnam_raju

Recommended Posts

HiPlease go through the code below.test.html-----------------------------------------------------------------------<html><head><script language=JavaScript>function transferview(image,iname,webaddress) {info="<TITLE>"+iname+"</TITLE><body topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0' bgcolor='#CEDDFF'><table width='498'; height='500' cellpadding='2' cellspacing='2' bgcolor='#CEDDFF'>" + " <tr>" + " <td colspan='2' align='center' valign='middle'><IMG SRC='"+image+"' BORDER=0 /></td>" + " </tr>" + " <tr>" + " <td width='243' height='22' align='center' bgcolor='#FFB7B9'><font face='verdana, arial' size='2' color='#000066'>"+iname+"</font></td>" + " <td width='243' height='22' align='center' bgcolor='#FFB7B9'><form method='post' action='"+webaddress+"'><input type='submit' value='Request open yahoo in parent window' /></form>" + " </td>" + " </tr>" + "</table></body>"ImageWindow=window.open("", "newwin","toolbar=no,scrollbars=no, width=500, height=500");ImageWindow.document.write(info)ImageWindow.document.close()}</SCRIPT></head><body><a href="#" onclick="java script:transferview('test.jpg','Click the button to open yahoo', 'http://www.yahoo.com')">Open Pop UP</a></body></html>--------------------------------------------------------------------------What it actually does is:when i click on the text link in the parent window, it pops up a child window with a button ( and an image). What i want now is, if i click the button in pop up window, it should open the specified URL in the Parent window (which is at the back) and the pop up window should close.Please help me, i tried , tried , tried and now tired.Can you help with the script and can you tell me what code to add and where exactly.Please advise.Thank youKrishnam

Link to comment
Share on other sites

This is the code you needed, open the new page in the opener and then close itself.<input type='button' value='Request open yahoo in parent window' onclick=\"window.opener.location.href='"+webaddress+"';self.close()\" /> :)

<html><head><script language=JavaScript>function transferview(image,iname,webaddress) {info="<TITLE>"+iname+"</TITLE><body topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0' bgcolor='#CEDDFF'><table width='498'; height='500' cellpadding='2' cellspacing='2' bgcolor='#CEDDFF'>" + " <tr>" + " <td colspan='2' align='center' valign='middle'><IMG SRC='"+image+"' BORDER=0 /></td>" + " </tr>" + " <tr>" + " <td width='243' height='22' align='center' bgcolor='#FFB7B9'><font face='verdana, arial' size='2' color='#000066'>"+iname+"</font></td>" + " <td width='243' height='22' align='center' bgcolor='#FFB7B9'><form><input type='button' value='Request open yahoo in parent window' onclick=\"window.opener.location.href='"+webaddress+"';self.close()\" /></form>" + " </td>" + " </tr>" + "</table></body>"ImageWindow=window.open("", "newwin","toolbar=no,scrollbars=no, width=500, height=500");ImageWindow.document.write(info)ImageWindow.document.close()}</SCRIPT></head><body><a href="#" onclick="java script:transferview('test.jpg','Click the button to open yahoo', 'http://www.yahoo.com')">Open Pop UP</a></body></html>

Link to comment
Share on other sites

That's because when you copy the one above it doesn add in any of the formatting. You will have to manually go through it and clean up the code ie add returns and white space or you could just replace that one line of code on your original...

Link to comment
Share on other sites

<html><head><script language=JavaScript>function transferview(image,iname,webaddress) {info="<TITLE>"+iname+"</TITLE><body topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0' bgcolor='#CEDDFF'><table width='498'; height='500' cellpadding='2' cellspacing='2' bgcolor='#CEDDFF'>" + " <tr>" + " <td colspan='2' align='center' valign='middle'><IMG SRC='"+image+"' BORDER=0 /></td>" + " </tr>" + " <tr>" + " <td width='243' height='22' align='center' bgcolor='#FFB7B9'><font face='verdana, arial' size='2' color='#000066'>"+iname+"</font></td>" + " <td width='243' height='22' align='center' bgcolor='#FFB7B9'><form><input type='button' value='Request open yahoo in parent window' onclick=\"window.opener.location.href='"+webaddress+"';self.close()\" /></form>" + " </td>" + " </tr>" + "</table></body>"ImageWindow=window.open("", "newwin","toolbar=no,scrollbars=no, width=500, height=500");ImageWindow.document.write(info)ImageWindow.document.close()}</SCRIPT></head><body><a href="#" onclick="java script:transferview('test.jpg','Click the button to open yahoo', 'http://www.yahoo.com')">Open Pop UP</a></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...