0

So I have been looking into this for a few weeks and have come up with nothing!

I work on the website for my families music store, and have been asked to add a "Links" page to the website. My goal would be to have the categories of our vendors (i.e. Violin, Guitar, Piano, etc.) on the left of the page and when the category is selected the links come up on the right. That part I have. The tricky part here is: When a link to a vendor (i.e. Fender, G&L, Yahmaha) is clicked instead of taking them directly to the site, I want it to take them all to the same page, but embeded on that page is the site.

I have done a lot of research on this and have come up with nothing. I could just go through and make a new page for each of the vendors, with the embedding on each individual page, but that is extremely time consuming with the amount of vendors.

Is something like this at all possible? I've been playing with embedding itself and have that down. It just comes down to, which link did they click, and loading that specific page.

If there is any more information you may need to help or point me in the right direction please let me know! Same with any code that may be helpful!

I've come up dead on all my research on this.

EDIT: I guess my ultimate goal is that it will look something like this: http://answers.yahoo.com/ so that the vendors website is open on bottom, but our stores banner and links are still at the top. Out website can be found here: http://www.brassbellmusic.com/default.aspx

Nick
  • 35
  • 6
  • What code have you tried ? Sounds like javascript might be helpfull for you here ... – Pogrindis Aug 24 '13 at 17:25
  • take a look here : http://www.dezinerfolio.com/2007/07/19/simple-javascript-accordions/ – Pogrindis Aug 24 '13 at 17:32
  • I don't know what it is I'm looking at when I click the link. I haven't tried any code thus far because I haven't been able to find anything close to what I'm looking to do. – Nick Aug 24 '13 at 19:03

1 Answers1

0

I've created a JSFiddle to demo this functionality using jQuery.

We iterate through the list of brand links in the ul:

$('#brandListing a')

Capturing a click event on each:

.click(function(ev){

jQuery passes an event object to the anonymous function (ev). When the link is clicked, we first must prevent the default action, which is to follow the link. Then we update the src attribute of the iframe (the "embedded page") with the value of the href that was clicked:

ev.preventDefault();
$('#embeddedBrandWebsite').attr('src', ev.target.href);

You'll need to add the jQuery library to your page to use my code sample, but it's possible to replicate the functionality without it.

EDIT

The sample above is for a single page implementation, where links and the embed are on the same page. To achieve the requested "transfer of information," I recommend passing the target href as a GET parameter (brassbellmusic.com/brandEmbed.aspx?path=http%3A//www.gibson.com/). On the single "embed" page, you can then extract this either on the server side to set the iframe's src, or using javascript. With javascript, you might use:

function getURLParameter(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
}

Source

And then after your document is ready, set the iframe src using getURLParameter('path').

Community
  • 1
  • 1
Everett Green
  • 632
  • 3
  • 8
  • Bear with me here, as I have been learning HTML as I go, and will be starting College as a CS major in a few weeks. You mention that it is possible to replicate this without jQuery? I would prefer to not have to install external things to help run the companies website. Secondly you mention passing the target as a `GET` but show with javascript? I would I go about this is just HTML? Lastly, on your JSFiddle the Gibson link does not work, but the Yamaha link is fine. – Nick Aug 24 '13 at 20:23
  • Sure, no problem. Your site already uses jQuery, so there wouldn't be an additional/external library. While it's possible to refactor to use raw JavaScript, I recommend leveraging the shortcuts the installed jQuery library provides. To leverage a GET parameter to set an iframe src without using JavaScript, you'll need to use a server-side language. Alternatively, you'll need a separate page for each brand. Unfortunately, Gibson's website prevents embedding from another domain by way of an X-Frame-Options header set to SAMEORIGIN. You will not be able to iframe their website. – Everett Green Aug 24 '13 at 20:52