PDA

View Full Version : "#blabla", how to take them off the url?



bladefinor
12-15-2008, 03:12 PM
Here's my problem:

I got a top page with two iframes in it. The 1st iframe is iframe1.html and the 2nd iframe2.html. The top page is index.html.
I click on a button in iframe2.html that goes to an ID named "blabla" in the 1st iframe (iframe1.html), so the link is "#blabla".
After that I want to go to an another ID in iframe1.html (through iframe2.html). That link is "#bleble", but the the 1st iframe's location is "iframe1.html#blabla", so it won't take me t "bleble", becayse then the link would be "iframe1.html#blabla#bleble".

I'm using this javascript codes as links right now (which doesn't work the second time i want to go to an ID):


parent.iframe1.location = parent.iframe1.location + '#blabla';

and

parent.iframe1.location = parent.iframe1.location + '#bleble';


So the thing is that I want to know if there's any code that takes off/deletes the old ID from the 1st iframe's url/location...
Any thoughts?

rangana
12-15-2008, 03:49 PM
Have you tried:


parent.iframe1.location = parent.iframe1.location.split('#')[0] + '#blabla';
parent.iframe1.location = parent.iframe1.location.split('#')[0] + '#bleble';

bladefinor
12-15-2008, 05:06 PM
now i tried, and that didn't work. nothing happened :/

jscheuer1
12-16-2008, 04:59 AM
That looks like it should work, perhaps you copied it incorrectly. Though, to be on the safe side, one should use the href property:


parent.iframe1.location.href = parent.iframe1.location.href.split('#')[0] + '#blabla';
parent.iframe1.location.href = parent.iframe1.location.href.split('#')[0] + '#bleble';

But what's wrong with:


parent.iframe1.location.href = 'iframe1.html#blabla';
parent.iframe1.location.href = 'iframe1.html#bleble';

??

If you want more help:

Please post a link to the page on your site that contains the problematic code so we can check it out.

diltony
12-16-2008, 10:14 PM
Have u tried parent.iframe1.location.hash as oppose to parent.iframe1.location.href .
If that doesnt work, let me know, i will lookup my old projects, i have something like that somewhere that works after alot of headache especially from fd

bladefinor
12-18-2008, 04:12 PM
That looks like it should work, perhaps you copied it incorrectly. Though, to be on the safe side, one should use the href property:


parent.iframe1.location.href = parent.iframe1.location.href.split('#')[0] + '#blabla';
parent.iframe1.location.href = parent.iframe1.location.href.split('#')[0] + '#bleble';

But what's wrong with:


parent.iframe1.location.href = 'iframe1.html#blabla';
parent.iframe1.location.href = 'iframe1.html#bleble';

??

If you want more help:

Please post a link to the page on your site that contains the problematic code so we can check it out.

thx, it works perfect :D

the other codes you asked why i don't use them s becuase it's not online one page in iframe1, i have other pages there too which uses the same code to "scroll"