The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> problem with linking to anchors within iframes using target="", problem with linking to anchors within iframes using target="&quo
oddpockets
post Dec 8 2010, 10:22 PM
Post #1





Group: Members
Posts: 3
Joined: 8-December 10
Member No.: 13,342



hi there,

i have just finished building a new site for the shop my girlfriend and i have set up, and i am having a little problem.

here's the story:

i am using a bit of javascript to add a smooth scroll to navigate between different parts of the site.
the main content of the site is all within a file called 'shop_frame.html' which is sitting inside of an iframe in the centre of the main page (index.html).
when a link is clicked in the menu, the content scrolls within the iframe to show the corresponding part of the site. eg. if you click on the word 'badges', it scrolls to the bit about badges, if you click on the word 'tshirts', it takes you to the bit about tshirts.

this is all done using anchors within the 'shop_frame.html' page.

i have given the iframe an id of 'if1' and when i link to an anchor within the iframe (from outside of the iframe) i add a target="if1" to the link. eg:

<a href='#prints' target="if1">prints</a>

so when the link 'prints' is clicked the iframe scrolls to the anchor #prints withing the shop_frame.html file.
and it works like a treat!!

so here's the thing -

i am using frame based web forwarding to forward my domain (oddpockets.com) to this new website, which i have housed off of an old site of mine (http://www.saleontomorrow.com/oddpockets/).

everything loads fine - all of the internal links within the shop_frame.html file, inside of the iframe, referencing anchors within the same file - all work fine, but as soon as you click a link outside of the iframe referencing an anchor within the iframe - no dice, and this error message pops up

The page at http://saleontomorrow.com says:
Access error "if1"

all of the links work fine if you view the site at it's location - http://www.saleontomorrow.com/oddpockets
so i was thinking it must be something to do with needing more specific target code now that the whole site is sitting within another frame. the frame on oddpockets.com has been given the name of mainframe (name="mainframe"). so i thought maybe i need to specify that i am wanting to target the frame "id1" within the frame "mainframe".

i decided to test the frame forwarding on my local files by copying the html from the oddpockets site into a blank document and then changing the frame's src to the local version of the site on my hard drive. i then opened this new "local version" of the forwarding page in firefox and everything works, suggesting that housing the site within another frame is not the problem at all.

all i can think the issue is, is that the files are on different servers, or maybe there is some security on my saleontomorrow server?

can anyone help me with this?

if i'm not making a lot of sense, you might find it clearer to look at the site files directly.

http://www.oddpockets.com - for the webforwarding page
http://www.saleontomorrow.com/oddpockets/index.html - for the site files

i would really appreciate any suggestions smile.gif

thanks in advance.

hank
x

This post has been edited by oddpockets: Dec 8 2010, 10:29 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 9 2010, 06:58 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 19,780
Joined: 9-August 06
Member No.: 6



I'm not totally sure my memory serves me right, but I think you are suppsed to "chain" the frame names with nested frames, i.e. you must get the frame name of the top level frameset in there too.

No harm trying anyway. As the name of the redirection's frame is "mainframe", instead of target="if1", try target="mainframe.if1".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Dec 9 2010, 06:59 AM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 19,780
Joined: 9-August 06
Member No.: 6



I'm getting second thoughts. Maybe that's only when you use JavaScript. blink.gif

Oh well, won't hurt to try.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 9 2010, 09:14 AM
Post #4


.
********

Group: WDG Moderators
Posts: 8,829
Joined: 10-August 06
Member No.: 7



QUOTE(oddpockets @ Dec 9 2010, 04:22 AM) *

the main content of the site is all within a file called 'shop_frame.html' which is sitting inside of an iframe in the centre of the main page (index.html).

The links point to the index page, shouldn't they point to the framed page "shop_frame.html"?

QUOTE
as soon as you click a link outside of the iframe referencing an anchor within the iframe - no dice, and this error message pops up

That's a javascript error. When I disable javascript the link seems to load a nested index page inside the iframe.

(For some reason the links framed by saleontomorrow.com resolve to http://www.saleontomorrow.com/oddpockets/index.html#prints while those in oddpockets.com resolve to http://www.saleontomorrow.com/oddpockets/#prints don't know if it matters, though.)

QUOTE
all i can think the issue is, is that the files are on different servers

Yes, or more specifically different domains. Browsers don't allow cross-domain scripting for security reasons. The best solution should be to get proper hosting instead of the current framing service. I also advice against using frames in the first place, they create problems both for users and search engines: http://htmlhelp.com/faq/html/frames.html#frame-problems

QUOTE
alert("it seems you are using internet explorer. we have designed this website with firefox in mind. have you considered using firefox?");

That's is not a good way to attract customers. And ironically http://www.oddpockets.com/ does work in my MSIE. tongue.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
oddpockets
post Dec 9 2010, 02:54 PM
Post #5





Group: Members
Posts: 3
Joined: 8-December 10
Member No.: 13,342



thanks so much guys for taking the time to help me with this.

QUOTE(pandy @ Dec 9 2010, 06:58 AM) *

No harm trying anyway. As the name of the redirection's frame is "mainframe", instead of target="if1", try target="mainframe.if1".


i have tried adding the mainframe name to the target and it doen't help. thanks for the suggestions.

QUOTE(Christian J @ Dec 9 2010, 09:14 AM) *

(For some reason the links framed by saleontomorrow.com resolve to http://www.saleontomorrow.com/oddpockets/index.html#prints while those in oddpockets.com resolve to http://www.saleontomorrow.com/oddpockets/#prints don't know if it matters, though.)


that's interesting, i might try forwarding the oddpockets domain to http://www.saleontomorrow.com/oddpockets/index.html instead of just the oddpockets folder, and then add the full anchor url to the links - <a href="http://www.saleontomorrow.com/oddpockets.com/pages/shop_frame.html#shirts" target="if1">tshirts</a>

might work? - probably not

QUOTE

Browsers don't allow cross-domain scripting for security reasons. The best solution should be to get proper hosting instead of the current framing service. I also advice against using frames in the first place, they create problems both for users and search engines: http://htmlhelp.com/faq/html/frames.html#frame-problems


if the problem is the cross browser issue, i guess i'll have to give up on the web-forwarding.

i have already read up on the issues with frames and i would rather not use them. i just couldn't find a way of achieving the smooth javascript scrolling without them. if i could achieve the same effect with a central div that only shows a portion of its content and could scroll to reveal other pieces of content, i would rather do this. do think this is possible?

QUOTE

alert("it seems you are using internet explorer. we have designed this website with firefox in mind. have you considered using firefox?");
That's is not a good way to attract customers. And ironically http://www.oddpockets.com/ does work in my MSIE. tongue.gif


yeah, some versions of IE are fine but others don't have a very good time. but even the ones that work use different paypal script.
if you add something to the cart, a new tab opens with the paypal cart info, giving you the option to pay or continue shopping. in FF if you click 'continue shopping' the tab closes relieving the original tab with the shop in it - perfect. however, if you hit 'continue shoppping' in IE, the tab does not close but instead grabs the page that you came from and loads it into the current tab. as my paypal buttons are within frames the tab loads the framed page - and you are missing the rest of the site and all of the navigation to the other parts of the site. if the user works this out and closes the tab, the original shop tab is revealed and all is ok, but it's very sloppy and not at all ideal.

i guess the key is to just avoid using frames.
does anyone know where i might be able to find help setting this up to scroll within one div?

thanks again for you help on this

hank

This post has been edited by oddpockets: Dec 9 2010, 02:56 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 9 2010, 06:15 PM
Post #6


.
********

Group: WDG Moderators
Posts: 8,829
Joined: 10-August 06
Member No.: 7



QUOTE(oddpockets @ Dec 9 2010, 08:54 PM) *

if i could achieve the same effect with a central div that only shows a portion of its content and could scroll to reveal other pieces of content, i would rather do this. do think this is possible?

The instruction in http://www.saleontomorrow.com/oddpockets/S...s/softscroll.js seems to say it works in a single page as well. Maybe you could use a single page with anchors, similar to http://www.alistapart.com/articles/eatcake/ ?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
oddpockets
post Dec 9 2010, 08:46 PM
Post #7





Group: Members
Posts: 3
Joined: 8-December 10
Member No.: 13,342



cracked it!

the same people who provided me with my cross frame smooth scroll javascript also have a scrolling div script -

http://scripterlative.com/files/softdivscroll.htm

i have reworked the site so it is all sitting in a central div now instead of an iframe and it all works!

this means that i have eliminated using frames for my content (other than one section which only contains photographs) - so the paypal script should work in IE without any problems, and i have now removed the annoying IE alert script.

thank you all for talking this through with me and leading me to this point - you are very kind smile.gif

i am mega stocked biggrin.gif

hank
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 3rd August 2021 - 04:58 AM