jaymc Posted October 10, 2006 Share Posted October 10, 2006 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 windowThis works fine in IE, however, in firefox, after clicking the link the window closes but google.com does not load in iframeObviously a cross browser issueBut, is their a way around this or an alternitive to achieve the same aspectThanks Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 10, 2006 Author Share Posted October 10, 2006 Link ammended: oops Quote Link to comment Share on other sites More sharing options...
fenway Posted October 10, 2006 Share Posted October 10, 2006 And does it work without the target? Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 10, 2006 Author Share Posted October 10, 2006 It needs the target though, as its loading the website inside an iframe Quote Link to comment Share on other sites More sharing options...
fenway Posted October 10, 2006 Share Posted October 10, 2006 I understand, I'm just trying to narrow down the problem. Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 10, 2006 Author Share Posted October 10, 2006 Just imagine a webpage with an iframe on itYou click a link from within that webpage and that brings up a popupIn 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.closeIt works 100% in IE. In firefox the popup closes but the request is not sent to the target Quote Link to comment Share on other sites More sharing options...
fenway Posted October 10, 2006 Share Posted October 10, 2006 Is it sent anywhere? Does it load in the parent window? Sounds like FF doesn't know where to find the target frame. Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 10, 2006 Author Share Posted October 10, 2006 Its not sent anywhere, it just doesnt load Quote Link to comment Share on other sites More sharing options...
fenway Posted October 10, 2006 Share Posted October 10, 2006 So the HREF doesn't work at all... I'm confused. Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 10, 2006 Author Share Posted October 10, 2006 <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 popupIn firefox it just closes the window popup Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 10, 2006 Author Share Posted October 10, 2006 I think firefox cant pickup the iframe name because its in a popupI was thinking about using window.locationwindow.artistnalbums.locationBut 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 likewindow.parent.artistnalbums.location (not sure of syntax) Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 11, 2006 Author Share Posted October 11, 2006 [b]Any ideas?[/b] Quote Link to comment Share on other sites More sharing options...
fenway Posted October 11, 2006 Share Posted October 11, 2006 window.parent sounds reasonable... you'll have to see how FF responds. Try making sure these objects exist as you move down the chain. Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 12, 2006 Author Share Posted October 12, 2006 Ive tried that, it doesnt work. I do recall it saying something about object non existantI hadwindow.parent.songs.location Quote Link to comment Share on other sites More sharing options...
fenway Posted October 12, 2006 Share Posted October 12, 2006 Well, post the code or a link to it, and I'll see what I can reproduce on my end. Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 12, 2006 Author Share Posted October 12, 2006 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted October 12, 2006 Share Posted October 12, 2006 I understand that... but I can't do anything with just one line of HTML. I'll need you to make a mock-up of the parent & child windows/frames. Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 14, 2006 Author Share Posted October 14, 2006 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] Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 15, 2006 Author Share Posted October 15, 2006 Any ideas Quote Link to comment Share on other sites More sharing options...
fenway Posted October 16, 2006 Share Posted October 16, 2006 Interesting... it looks like the onclick happens before the href, so self.close() closes the pop-up window without executing the href. If you were to remove the onclick handerl, you'd see that everyone was OK. Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 16, 2006 Author Share Posted October 16, 2006 Yes your right, removing the OnClick handler does allow the content to load in the frameBut, I really do need the OnClick handler to workSo what is the solution or are you all stuck for answers?Cheers Quote Link to comment Share on other sites More sharing options...
fenway Posted October 16, 2006 Share Posted October 16, 2006 To be honest, I've never encountered this problem before, because I don't use pop-ups ever. I don't think you can reference this pop-up from the IFRAME, though I don't really know... I'll think about it. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted October 16, 2006 Share Posted October 16, 2006 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 Quote Link to comment Share on other sites More sharing options...
tomfmason Posted October 16, 2006 Share Posted October 16, 2006 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 Quote Link to comment Share on other sites More sharing options...
jaymc Posted October 16, 2006 Author Share Posted October 16, 2006 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.closeThanks for the help :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.