Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Oregon City
    Thanked 50 Times in 49 Posts

    change an elements properties in window.open

    hey, is there any way i can change an elements properties in window open?

    i click a link and it opens a window with window.open, and i want to take something from the current page and place it inside a textarea within the opened window.. is it possible?

  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Thanked 665 Times in 660 Posts
    it depends greatly on whose page it is. If it's your page that you are opening then all you have to do is open the window with a query string, parse that out as it opens and add the string to the text box.

    If it's somebody else's page you are opening it gets a little tricky - you have to know if the page accepts query strings and how it processes them. Here's how to open a window searching for "horse meat" in google, for example:
    window.open('http://www.google.com/search?q=horse meat')

  3. #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Sydney, Australia
    Thanked 932 Times in 919 Posts
    If the page is on the same domain then you can just reference the other window by the name you assigned what the window.open returned to.

    If it is on a different domain but you have access to add JavaScript to both then you can use postMessage() to pass information between them.

    If it is on a different domain where you don't have access to the JavaScript there then you have no access to do anything with it unless the owner of the page builds in appropriate JavaScript to allow the interaction.
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts