|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Redirection issue
how do I make a page redirect traffic unless called by a certain page
update* ok what im trying to do is to redirect traffic from certain pages back to my index page and the call the page it was redirected from in an iframe. Last edited by ajwtech : May 5th, 2008 at 03:09 PM. Reason: not enough info |
|
#2
|
||||
|
||||
|
Quote:
The child document has to check whether or not it is contained in a frame, and if not redirect to the parent with a querystring parameter, which the parent reads to determine which page to load into the iframe. Code:
if(self==top) location.href='http://myurl.com?load=framedDoc.htm' Then the parent document would have to act on any parameter, perhaps something like this: Code:
var ifDoc;
if( (ifDoc=location.search.match(/\bload=(.+)&|$/)) )
document.getElementById('theIframe').src=ifDoc[1];
Last edited by Arty Effem : May 7th, 2008 at 05:27 PM. |
|
#3
|
|||
|
|||
|
...
thanks a lot for your response. could you clarify the second function i dont normally javascript.
thanks again. adam |
|
#4
|
||||
|
||||
|
Quote:
Just change the id to match that of your iframe. You must place the script block somewhere below the relevant <iframe> tag. |
|
#5
|
||||
|
||||
|
There's a little bug in that regex... It should look more like the one posted below; otherwise the iframe will be redirected every time, and possibly to the wrong location.
Code:
/\bload=(.+?)(?:&|$)/ |
|
#6
|
|||
|
|||
|
thank you that was becoming an issue.
btw good eye |
|
#7
|
|||
|
|||
|
bload
what is bload?
|
|
#8
|
||||
|
||||
|
"bload" is meaningless. \bload, on the other hand, means (in the context of a regular expression) "a word boundary followed by the plaintext load". To learn more about special characters in regular expressions, visit regularexpressions.info or read Mastering Regular Expressions.
|
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Redirection issue |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|