radiohomer Posted June 3, 2011 Share Posted June 3, 2011 ok so its as the title says is there a way to open a new window and close the old one? ok so ill explain a little more on what i want to achieve i have 2 pages index.php page1.php on the index.php page i have a dropdown box with 3 options <select> <option>--Choose--</option> <option onclick="window.open('index.php')">Index</option> <option onclick="window.open('page1.php')">Page 1</option> </select> ok so the dropdown box is doing what i would like by opening a new window but i would like to close the old one. at the moment this is whats happening the user is viewing "index.php" he clicks on the dropdown and selects "Page 1" this opens a new window displaying the content of page1.php but the index.php page is still open. this is what i would like to happen the user is viewing "index.php" he clicks on the dropdown and selects "Page 1" this opens a new window displaying the content of page1.php and also closes index.php. is this possible?? i just cant get it to work... i have seen it done before but cant find the website that i saw it on i have tried using onclick, onchange ect ect if anyone could help me with this that would be great Link to comment https://forums.phpfreaks.com/topic/238332-is-there-a-code-to-open-a-new-window-and-close-the-old-in-one-click/ Share on other sites More sharing options...
fugix Posted June 3, 2011 Share Posted June 3, 2011 could try something like <option onclick="window.open('page1.php'); window.close('index.php')">Page 1</option> Link to comment https://forums.phpfreaks.com/topic/238332-is-there-a-code-to-open-a-new-window-and-close-the-old-in-one-click/#findComment-1224815 Share on other sites More sharing options...
radiohomer Posted June 3, 2011 Author Share Posted June 3, 2011 could try something like <option onclick="window.open('page1.php'); window.close('index.php')">Page 1</option> thanks for your input Fugix i have just tried that and it didnt work i have found a different way to do this my whole reason for the code above was because index.php has 3 frames on there and whenever i clicked a link it just opened in that frame and left the rest showing the content from index.php i never thought to use parent.top or target="_top" here is the code i have used and have got working <select> <option>--Choose--</option> <option onclick=parent.top.location="index.php">Index</option> <option onclick=parent.top.location="page1.php">Page 1</option> </select> this gets rid of the frames on the index page and loads page1.php in the full view Link to comment https://forums.phpfreaks.com/topic/238332-is-there-a-code-to-open-a-new-window-and-close-the-old-in-one-click/#findComment-1224816 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.