Web Design Forums

Javascript, AJAX, and JSON

Having problems with Javascript? Need help picking a library? Post your questions here.

close and redirect



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old December 3 '05, 03:50 PM (#1)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
close and redirect

Can any point me in the right direction for some code to close and browser window and open and new one in one action??

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 4 '05, 05:15 AM (#2)
hyperair is offline
--Nerd--
 
hyperair's Avatar
 
Join Date: May 2005
Posts: 452
hyperair is just really nicehyperair is just really nicehyperair is just really nicehyperair is just really nice
to close a window.. use a javascript code:
window.close();

to open a new window..
window.open(url,target,properties); or in html, <a href="url" target="_blank">click here</a>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 4 '05, 07:15 AM (#3)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
Quote:
Originally Posted by hyperair
to close a window.. use a javascript code:
window.close();

to open a new window..
window.open(url,target,properties); or in html, <a href="url" target="_blank">click here</a>

Isnt that two actions? I need to do it in one action? Open a window and close the old one?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 4 '05, 08:51 AM (#4)
hyperair is offline
--Nerd--
 
hyperair's Avatar
 
Join Date: May 2005
Posts: 452
hyperair is just really nicehyperair is just really nicehyperair is just really nicehyperair is just really nice
hmm i see. so you want to close the window and open a new one eh..
<script type="text/javascript">
// <![CDATA[
function openclose(url,target,properties) {
window.close();
window.open(url,target,properties);
}
// ]]>
</script>

just paste this somewhere in your page. when you want to open a new page then you can use the function by:

openclose(url,target,properties);

would that work for you?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 4 '05, 05:10 PM (#5)
Fallout is offline
I <3 PHP
 
Fallout's Avatar
 
Join Date: August 2003
Location: Richmond, Virginia
Posts: 543
Fallout is on a distinguished road
Wouldn't you want to open the window first, then close the parent? A window that is already closed can't execute the JS to open a new one because it is already gone. Untested, but you want something like:

Code:
<script type="text/javascript">
// <![CDATA[
function openclose(url,target,properties) {
window.open(url,target,properties);
window.parent.close();
}
// ]]>
</script>
Most browsers will throw up a warning message if a script tries to close what it thinks is the "main" broswer window, however. It could be seen as a phishing attack otherwise.

Last edited by Fallout; December 4 '05 at 05:10 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 4 '05, 10:53 PM (#6)
hyperair is offline
--Nerd--
 
hyperair's Avatar
 
Join Date: May 2005
Posts: 452
hyperair is just really nicehyperair is just really nicehyperair is just really nicehyperair is just really nice
actually, the warning mesage will popup, then if the user clicks yes or ok, then it will execute the remaining statements. then it will close.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 5 '05, 06:00 AM (#7)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
Nice1. Thanks for the code....

Is there not away to do this without the browsers asking YES or NO??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 5 '05, 06:32 AM (#8)
hyperair is offline
--Nerd--
 
hyperair's Avatar
 
Join Date: May 2005
Posts: 452
hyperair is just really nicehyperair is just really nicehyperair is just really nicehyperair is just really nice
sure.. i did some research and this is what i found. copy this code:

Code:
<script type="text/javascript">
// <![CDATA[
function openclose(url,target,properties) {
opener = top;
self.close();
window.open(url,target,properties);
}
// ]]>
</script>
now u can close the window and open a new one by calling:
Code:
openclose(url,target,properties);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 5 '05, 07:06 AM (#9)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
Ok i know now I'm gona sound like a complete f**k wit but i truly not a programmer. Can you put it into a easyer format. I'm not sure what goes where. Tar.......
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 5 '05, 09:29 AM (#10)
hyperair is offline
--Nerd--
 
hyperair's Avatar
 
Join Date: May 2005
Posts: 452
hyperair is just really nicehyperair is just really nicehyperair is just really nicehyperair is just really nice
sorry sorry, my mistake. this goes inside the <head> section of the html document.

<script type="text/javascript">
// <![CDATA[
function openclose(url,target,properties) {
opener = top;
window.open(url,target,properties);
self.close();
}
// ]]>
</script>

then, to use this.. you can have something like:

<a href="lala.html" onclick="openclose("something.html","_blank","");">click here</a>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 5 '05, 11:06 AM (#11)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
You are a star. Tahnsk. Gona try it in a bit....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 6 '05, 01:53 PM (#12)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
well tried it and got no where?????

The page just went to a the next link when i filled it in?

I want to shut down the present page and link to goto To view the link you have to Register for example

Its a hide site function so the last page cant be viewed by going back using the browser back button

Im just not getting it. ;-( Any further help welcomed. Tar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 6 '05, 09:11 PM (#13)
hyperair is offline
--Nerd--
 
hyperair's Avatar
 
Join Date: May 2005
Posts: 452
hyperair is just really nicehyperair is just really nicehyperair is just really nicehyperair is just really nice
er sorry.

<a href="javascript:void(0)" onclick="openclose('lala.html','_blank','');">click here</a>

i think this should work. however, i advise against using popups, because most people use popup blockers nowadays, so if the popup is blocked, the page will just close, and no new window will popup.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 9 '05, 08:13 AM (#14)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
cool works great in IE but not in Firefox or netscape? is there a hack for these browsers??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 9 '05, 08:21 AM (#15)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
sorry seems to work now???? Hummmmmmm.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 9 '05, 08:21 AM (#16)
hyperair is offline
--Nerd--
 
hyperair's Avatar
 
Join Date: May 2005
Posts: 452
hyperair is just really nicehyperair is just really nicehyperair is just really nicehyperair is just really nice
firefox 1.5 doesnt seem to allow closing of windows. so im sorry but i dont think its possible.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 9 '05, 08:50 AM (#17)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
na something to do with the java settings on Firefox??? Thanks all the same but dont think this one is gona work across all browers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 9 '05, 11:21 AM (#18)
joenebula is offline
WDF Member
 
joenebula's Avatar
 
Join Date: June 2005
Posts: 21
joenebula is on a distinguished road
Had to use this in the end. the same effect

<span onclick="location.replace('http://news.bbc.co.uk/')">hide Site</span>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » Javascript, AJAX, and JSON

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 10:36 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163