|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
HTML: Catching a URL
Hi,
I want to catch a url and direct from _top to an iframe. I need to do this because I am making a site tutorial on how to navigate around the site. The problem is I don't have access to code to change target or anything like that. So when a user clicks on a link that looks like the following: <a href="page.html" target="_top">Link</a> The page loads up breaking the frames, so i was think of invoking a url catch and redirect with the onUnload event. I don't know if this is even possible. Once I get the url then I can get it to show in the right spot. |
|
#2
|
|||
|
|||
|
Hey,
You can just use something like function catchIt() { if(document.frames[0].location.href = 'toppage.html') document.myiframe.location.href = 'somepage.html'; } <body onBeforeUnload="catchIt()"> |
|
#3
|
|||
|
|||
|
Well there are quite a few urls, and I don't want to hard code these as they can change.
Is there a way to target just urls that go <target="_top">? I'll try what you suggested and see I can make it work |
|
#4
|
|||
|
|||
|
You are talking about re-framing and orphaned frame page. I would write the IFRAME object with javascript, so you can then use a variable for the SRC.
I wrote a JS include that handles this sort of thing, you can get it here: http://www.peterbailey.net/js/superframes.js The documentation in that file only mentions FRAMESETs, but it can just as easily work for IFRAMEs as well. Enjoy! |
|
#5
|
|||
|
|||
|
I can't see how this will help.
You see imagine you are trying to do what hotmail does, when you click on an external link it opens a new window and sticks the site in frames, with your banner up the top and the external site in the bottom frame. Now because the webmaster dosen't like having his site in frames he sticks "target=_top" in all his links because he uses tables instead of frames and this doesn't affect his site, just people who try to stick his site in frames. What I want to do is somehow intercept this "target=_top" and send the url to my iframe via SRC instead of _top. Do you see what I'm trying to do now? Your scripts needs stuff passed to the function, how can I pass stuff to the function if I can't alter the code if I don't have access to it use the function? So what I'm trying to do is grab the url that the page wants to change to once I know how to do this I'll just use a function like yours and send the url to the iFrame. Nigorr |
|
#6
|
|||
|
|||
|
I see. Well, once a link targets the top, any page/code you have will be unloaded. You could use the 'onUnload' method, but it can't be canceled, so that won't help a whole lot either.
the only way I can see you accomplishing this is to open a popup window that monitors the status of the main window, checking to see if the page containing the IFRAME is unloaded, and the reloads it with the requested page as the src. EDIT: There is another event called 'onBeforeUnload' that operates just like 'onUnload' except that it can be cancelled. However, I'm pretty sure it is proprietary to IE. Of course, all this may be a moot point because I'm not sure how to capture the incoming URL without the window acutally loading it... Last edited by beetle18 : July 30th, 2002 at 08:52 AM. |
|
#7
|
|||
|
|||
|
Ok, thanks for your help, I'll look into it and post a solution when I get one.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > HTML: Catching a URL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|