Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Window.opener

Recommended Posts

worked on a simple window.opner() and it worked fine like this.

function popupwindow() { var window_open = window.open('childwindow.html','venderfindwindow','width=1000,height=700'); } </script> <form name="productCode"> <input type="text" name="Vender1" id="Vender1" width="45"> <input type="button" value="Find" onClick=popupwindow(); return false;") </form>




<form name="vederlookup"> <input type="text" value="" name="Vender1" size="5"></td></tr> <a href="javascript: doStuff('this');">close</a> </form> function doStuff(findItem){ window.opener.document.getElementById('Vender1').value=findItem; window.close(); } 


The above worked as expected. However, when I change the second file like this it does not close the window or communicate to the parent window. I wonder what am I doing wrong?


<form name="venderlookup"> <input name="searchtext" value=""><input type="submit" value="Search" onClick='goSearch()';>   </form> <script language="JavaScript"> function goSearch() { document.write("hello world!"); document.write('<form name="form1">');     document.write('<a href="javascript: doStuff("this");">close</a>'); document.write('</form>'); }



The last example does not close the window. Could you do like this" document.write('<a href="javascript: doStuff("this");">close</a>');"

Also, when I call my function goSearch() it takes removes the form from the screen and just shows the output of the function. Is it possible to continue to view the form without using frames?

Notice from snlildude87:
Use code BBCode tags

Edited by snlildude87 (see edit history)

Share this post


Link to post
Share on other sites

Because, of your use of " and '

 

<a href="javascript: doStuff("this");">

 

It should be:

 

<a href="javascript: doStuff('this');">

 

Your using the speech marks in the command 2 times so html will close the command when it sees the speech marks again. So it sees what your trying to do as this:

 

<a href="javascript: doStuff("this");">

 

The part in red is how it sees your link. The other part in blue it sees as stuff it doesn't need so it springs up a code error and doesn't work. Understand?

 

Right, now you want to write it in javascript and you want to use 3 types of speech marks for that but you only have 2 (' and ").

 

So you need to write it like this:

 

document.write("<a href=\"javascript: doStuff('this');\">");

 

I've added red marks where the key is the backslash. This is javascript 3rd speech mark only to be used inside document.write() and is the the answer to your worries!

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.