Forum Moderators: open

Message Too Old, No Replies

DIV Swap on a new page

swapping to a DIV when going to a new page

         

jerkhammer

7:45 am on Sep 16, 2009 (gmt 0)

10+ Year Member



I set up a clothing website, and thumbnail images link to a DIV swap and display the main image on the opposite of the page.

Is there a way to hyperlink to a new page, and switch to a DIV?

Does this make any sense?

whoisgregg

5:10 pm on Sep 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld!

You can have any link target a new window like so:

<a href="http://www.example/com" target="_blank">Opens in new window</a>

Is that what you're looking for?

jerkhammer

8:20 pm on Sep 16, 2009 (gmt 0)

10+ Year Member



Thank you for the reply.

This doesn't serve as a solution.

Let me try to explain it better.

I set up a page with two columns. On the right there are thumbnails for products, and on the left there is a main detail shot of the product. When the right thumbnail is clicked the main detail DIV is swapped out to display a new DIV (a new detail shot).

What I am trying to do, is link directly to the second, or third DIV. So say I'm on a random page, and I want to link directly to the third detail shot of an item how do I link to that.

Right now it just links directly to the default DIV on the page.

whoisgregg

9:13 pm on Sep 16, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So basically, you want to be able to add a link like...
http://www.example.com/product_1.html#photo_2

...and when the user clicks that link, it automatically loads up the second photo?

You can do this by setting up your product page to look for an initial hash tag value. Here's some basic code to get you started.

window.onload=function() { 
if(location.hash.replace(/#/,'') != undefined && location.hash.replace(/#/,'') != ''){
your_function_to_swap_divs( location.hash.replace(/#/,'') );
}
}

You'll want to make sure in your function that it checks to make sure the anchor is a valid image on the page.