I am new to DOM and need a little help. I have opened a named page with window.open. Later when the user clicks on the link from the parent page that was used to open the child window, they are confused because they think the function doesn't work. Of course, the page is already open. All I need is the code to bring the child window back to the front. I assume I will need to use focus() and have tried everything I can think of. Do I need an if statement on the function that opens the child window to determine if the child window is already open and what is the DOM code i.e. window.childWindowName.focus()? Thanks in advance for your help!
JC4QLx3
0
Newbie Poster
Recommended Answers
Jump to PostWhen the button is clicked, check to see if the window is already open using the 'window.closed' property which returns a boolean. If the child window is open, just give it the focus using the function 'focus()' and if it isn't then open a new one.
<html> …
Jump to PostYour code does not run because you ignore the important aspects of the code posted by me. You have a global variable called 'name' and at the same time have a local variable 'name'. Because of this the local one hides the global one. Change the name of the function …
Jump to PostDo something like this:
<SCRIPT> var name = null; function openWindow(url, named) { if(!name || name.closed) { var windowHeight,windowWidth,windowTop,windowLeft windowHeight = screen.availHeight; windowWidth = screen.availWidth; windowTop = 0; windowLeft = 0; var varStore = ""; varStore = varStore + "width=" + windowWidth; varStore = varStore + ",height=" …
Jump to PostActually, you should not use html attributes as variable names.
All 16 Replies
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
JC4QLx3
0
Newbie Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
JC4QLx3
0
Newbie Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
MidiMagic
579
Nearly a Senior Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
JC4QLx3
0
Newbie Poster
JC4QLx3
0
Newbie Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
JC4QLx3
0
Newbie Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
JC4QLx3
0
Newbie Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
JC4QLx3
0
Newbie Poster
~s.o.s~
2,560
Failure as a human
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.