Hello and welcome to our community! Is this your first visit?
Register
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
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    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
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,980
    Thanks
    56
    Thanked 557 Times in 554 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:
    Code:
    window.open('http://www.google.com/search?q=horse meat')

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 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.
    Stephen
    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
    •