Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

New browser window

SaMoSaMo Posts: 36Member
Hi!

What I am basically trying to do is the following. Suppose I have a page and a link on it. As I click it, new browser window opens. OK, this is pretty straigtforward, so no problem. The most interesting part of the story though is that I want HTML in that newly opened window to be created on the fly. I tried to do it using the document.write('here comes HTML') function. The problem is that this code then applies to my initial window, not newly opened one, which is of course not what I want.

The question is then how to make it apply to a creted window?
Any help highly appreciated.

Comments

  • WeirdofreakWeirdofreak Posts: 439Member
    I'd assume you're using target=_blank to open the new window? You'll have to change that. Use something like targe=newwindow and then access the window with the sam name - newwindow.document.write().
  • SaMoSaMo Posts: 36Member
    : I'd assume you're using target=_blank to open the new window? You'll have to change that. Use something like targe=newwindow and then access the window with the sam name - newwindow.document.write().
    :

    OK, let's put it this way. To create new browser window I use the following code:

    onClick="window.open('URL', 'Mine', 'width=400, height=400')"

    Where 'URL' is the page I wanna open, 'Mine' is the name of this new page, and the rest is attributes of the new browser window.

    Firstly, where should I put 'target=newwindow' text? I believe the list of attributes does not include that. Moreover, the text 'Mine' in the function already indicates that new window has a name 'Mine' that I can theoretically use to address this new window. However, the following code:

    Mine.document.write('text');

    results in an error on page, and I actually don't get what is the problem.
  • WeirdofreakWeirdofreak Posts: 439Member
    I assumed you were using HTML to open it, so you can ignore that bit.

    Mine.document.write should work though, the only reason it wouldn't that I know of would be that you're using NS4 and didn't do the obligatory Mine.document.close (I only just found out about it myself).

    http://www.quirksmode.org/?/js/popup.html might be of some use, although I didn't see anything else that might have caused it to not work.
Sign In or Register to comment.