Jump to content

Window Close function doesn't


thesoundsmith

Recommended Posts

I don't know why this doesn't work. It's the same old standard window.close dialog I see everywhere (and tried several versions-form, anchor, etc. to no avail. Must be something stupid, but I can't see it.The page is the Not Ready dialog and should simply close the window. But it doesn't.The code that calls the window is constructed when a new song loads into the player: I create a button that holds the link.

function printItemData(theIndex) {	var plst = null;	plst = player.getPlaylist();	if (plst) {		var txt = '';		  txt += '<li><a id="btn2" class="button2" target="_blank" href="' + plst[theIndex].link + '">' + ' Buy Now ' + '</a></li>';	var tmp = document.getElementById("itmsDat");		if (tmp) { tmp.innerHTML = txt;}	}}

and the button itself is:

<a id="btn3" class="button2" href="#" onclick="return targetopener(this,true,true)">Close</a>

or:

<a id="btn1" class="button2" href="#" onclick="window.close()">Close</a>

I probably need to alter the embedded code in the 'txt' var, but I don't see the solution, nor do i prefer it. This code validates, and works except for the closing issue. I'd hope to just use a reliable, don't care who-called close. I have also used the simpler forms of windwo.close Thanks.

Link to comment
Share on other sites

are you having problems with a specific browser? It worked just fine for me in FF.
Here's a clue - I also use FF. I called it from THIS SITE and it closed properly. When I went to my home page and type in the rest of the page address (notfound.htm) the page loads and does NOT close. Nor when it is called from the Radio.htm page (that is the only page that calls this one.) Calling thesoundsmith.com/radio.htm will bring up the page, but the size is incorrect.The menu call is:
<a class="radmenu" href="radio.htm" title="Play DashRadio" onclick="return popup(this, 'DashRadio')">DashRadio</a>

You can see that code at the radio page,, but it is called from the site upper-left menu. I

Link to comment
Share on other sites

This sort of thing worked way back when, but there are new rules in place. Very simply, it says this. If Document A opens Window B, then Document A can also close Window B. If Document A is simply loaded into Window B, then it may not close Window B.Think of this from a client's perspective. I've been surfing the net for an hour. There are places in my history I want to come back to. I have forms almost completed, but cannot be finished till my partner gets home and provides some information. I am counting on the documents looking just the way they were when I left them.Now I get to www.malicious.com, and a script closes my window. WHAT?!? All my history is gone. My forms are wiped.Closing a document is not the same as closing a window. That window is the client's. It is only your document's window if your document explicitly opens it. Then you have the right to close it. That is why you can close a popup window. You popped it up, so you can close it.

Link to comment
Share on other sites

This sort of thing worked way back when, but there are new rules in place. Very simply, it says this. If Document A opens Window B, then Document A can also close Window B. If Document A is simply loaded into Window B, then it may not close Window B.
But while I'm fine with Window A, being able to close Window B, I also (and prefer) that Window B be able to close Window B. The code I was using didn't work, but I think I had a cache issue, when I try it now in Firefox, it does close. In IE I get the dialog, but I can work with (or around) that.My goal is to allow the visitor to click on any of the 'Radio' page links, and open a small secondary window that plays random selections from my site. Once the window is open, the visitor can browse anywhere on the web he likes, while my window streams music in the background. If he/she hears a song they like, they can click the "Buy Now" button and be directed to my shopping cart page with that song ready to purchase.But not all songs are available. Thus the NotReady (and NotAvaiilable) pages that explain, "Sorry..." I then need to let the visitor close that page gracefully (or go the the store, but that's just a standard link.My other option, and I would prefer it, is to somehow test the 'link variable, and if it had a specific value, instead of the Buy Now button, they would get a "Not Avail" or Not Ready" button that did nothing. But that is way over my current javascript comfort zone.But I just realized the significance of what you said. I can be in the middle of a transaction on Window B, and if I close Window A, the transaction page goes away also. Oops! Thanks for the heads-up.Is there a user-friendly way to deal with this, by how I instantiate the window? Can I call the 'store' window as a totally independent entity, or must it always be slaved to the caller? I thought using target="_blank" avoided that, but obviously I'm mistaken.
Link to comment
Share on other sites

maybe some sort of interactive light-box type of page? So people can do "secondary" methods on your site (seeing songs, transactions, etc, anything you would want to appear in a pop-up or second window) and (if light-box works that way), use AJAX to test responses from the server so you can pre-load certain message if the link is broken, or something like that.

Link to comment
Share on other sites

maybe some sort of interactive light-box type of page? So people can do "secondary" methods on your site (seeing songs, transactions, etc, anything you would want to appear in a pop-up or second window) and (if light-box works that way), use AJAX to test responses from the server so you can pre-load certain message if the link is broken, or something like that.
I'm not clear on what you're suggesting, but I'll look into the lightbox concept. I don't know that JW Player will run in one, tho...
Link to comment
Share on other sites

lightbox is an effect that "dim's" the current page and brings a smaller page into focus. I've seen it used when pages offer you ringtone downloads, or people seem to use it a lot for loading pictures when you click on a thumbnail. I'm pretty sure its part of JQuery, and must be customizable to some extent. People wouldn't necessarily open a new page, they would just be focused on this newer page over the old one, which you could bring up when downloading songs, checking out, etc if you didn't want to load a whole new page. However, I'm not entirely sure how much you can load into the page, or whether you can load a PHP page into and get data from a database.

Link to comment
Share on other sites

lightbox is an effect that "dim's" the current page and brings a smaller page into focus. I've seen it used when pages offer you ringtone downloads, or people seem to use it a lot for loading pictures when you click on a thumbnail. I'm pretty sure its part of JQuery, and must be customizable to some extent. People wouldn't necessarily open a new page, they would just be focused on this newer page over the old one, which you could bring up when downloading songs, checking out, etc if you didn't want to load a whole new page. However, I'm not entirely sure how much you can load into the page, or whether you can load a PHP page into and get data from a database.
Actually, that gives me an idea - maybe my real solution is to re-size the Radio page back up to normal and then call the php page - if I can resize the page, I'm sure I can remove the target=blank reference. That way I never leave the original page, and the customer can always open another 'radio' dialog if they wish...
Link to comment
Share on other sites

Well, I got it working. I'm not sure what changed, I am sure I have tried this version before, but I believe I was caught in the cache trap and didn't realize I had a fully functioning page. I am doing everything i wish - random song selection via the 'Next' button, the Buy Now links to a separate normal web page, either the requested link or two pages for unavailable and Not Ready songs. Everything actually works, amazing! :) Thanks for the help and ideas.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...