Jump to content

self.close firefox


jaymc

Recommended Posts

Right, Take a look at this link

[code]<A href=http://www.google.com target=iframe "OnClick=javascript: self.close()"><b><u>Close this window</u></b></a>[/code]

That link is in a popup, when someone clicks the link it will load google in the iframe window and close the window

This works fine in IE, however, in firefox, after clicking the link the window closes but google.com does not load in iframe

Obviously a cross browser issue

But, is their a way around this or an alternitive to achieve the same aspect

Thanks
Link to comment
Share on other sites

Just imagine a webpage with an iframe on it

You click a link from within that webpage and that brings up a popup

In that popup you have a link with a target to the iframe name, and on clicking that link it also uses an OnClick handler to initiate self.close

It works 100% in IE. In firefox the popup closes but the request is not sent to the target
Link to comment
Share on other sites

<a href='searchresults.php' target='artistnalbums' OnClick="javascript: self.close()"><b><u>Load results in main site</u></b></a>

That works in IE, loads the searchresults.php in artistnalbums iframe and closes the window popup

In firefox it just closes the window popup
Link to comment
Share on other sites

I think firefox cant pickup the iframe name because its in a popup

I was thinking about using window.location

window.artistnalbums.location

But it cant find that either, so how could i add in the _parent so it knows to look for the main page with the iframe on. Maybe like

window.parent.artistnalbums.location (not sure of syntax)
Link to comment
Share on other sites

Here is the link code

[code] <a href='searchresults.php?viewresults=yes&criteria=g&searchby=SONGNAME' target='songs' OnClick="javascript: self.close()"><b><u>Load results in main site</u></b></a>[/code]

That code is inside of popup that was loaded from the parent site. The target 'songs' it is referring to is an iframe that is nested in the parent site
Link to comment
Share on other sites

paste this into a file called 'mainsite.htm'

[code]<html>
<head>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function audiosearch(url)
{
newwindow=window.open(url,'name','height=106,width=378');
if (window.focus) {newwindow.focus()}
return false;
}

// -->
</SCRIPT>
</head>
<body>

<a href=# Onclick="javascript:audiosearch('search.htm')"><u>Search</u></a>
<BR><BR>

<iframe src=http://google.co.uk height=400 width=600 name='framer'></iframe>

</body>
</html>[/code]

And this into a file called 'search.htm'

[code]<a href='http://yahoo.com' target='framer' OnClick="javascript: self.close()"><b><u>Load and close</u></b></a>
[/code]
Link to comment
Share on other sites

This may help with targetting the a frame in the main window then set a small delay before closing the poup window.
I have yet to test this but give it a try..

[code=php:0]
function something() {
    if (opener.frames['yourFrame'].location.href = 'yourpage.html') {
        setTimeout('self.close();', 1000);
    }
}
[/code]

then <a href="#" onclick="something();">Something</a>

Hope that helps,
Tom
Link to comment
Share on other sites

Yea I tested that and it works fine in FF, Opera and IE6.. You could have less of a delay but you will still need one for fire fox.

Also, this will only work if you are trying to change the location of a frame on the page that you opened the popup from.

Good Luck,
Tom
Link to comment
Share on other sites

Ive got it working

[b]<a href='searchresults.php?viewresults=yes&criteria=f&searchby=ARTISTNAME' OnClick="opener.frames['artistnalbums'].location.href = 'searchresults.php?viewresults=yes&criteria=f&searchby=ARTISTNAME'; javascript: self.close();" target='artistnalbums'><b><u>Load results in main site</u></b></a>
[/b]

I just had to put the location in an OnClick handler aswell and make sure it was before the self.close

Thanks for the help :D
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.