SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Enthusiast sparq-l's Avatar
    Join Date
    Mar 2001
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help making a jscript

    here is my new site i am working on http://www.sparq-l.com/v4/main.shtml

    I need the drop down menu to be navigation. Problem is, some of the links (ie: about) need to target to the iframe that has the text in it. While others have to open in new windows. Following is the jscript i am using to link to pages in thier own window.

    Code:
    function go_nav(){
    	if (document.select1.more.options[0].selected) parent.location.href = "#";
    	if (document.select1.more.options[1].selected) parent.location.href = "http://www.sparq-l.com";
    	if (document.select1.more.options[2].selected) parent.location.href = "http://www.sparq-l.com/forum/ikonboard.cgi";
    	if (document.select1.more.options[3].selected) parent.location.href = "http://www.sparq-l.com/about.shtml";
    	if (document.select1.more.options[4].selected) parent.location.href = "http://www.sparq-l.com/webcam.shtml";
    	if (document.select1.more.options[5].selected) parent.location.href = "http://www.sparq-l.com/portal";
    	if (document.select1.more.options[6].selected) parent.location.href = "#";
    	if (document.select1.more.options[7].selected) parent.location.href = "http://www.sparq-l.com/projects.shtml";
    	if (document.select1.more.options[8].selected) parent.location.href = "http://www.sparq-l.com/wallpaper.shtml";
    
    }
    
    function go_nav2(){
    	if (document.select2.more2.options[0].selected) parent.location.href = "index.shtml";
    	if (document.select2.more2.options[1].selected) parent.location.href = "http://www.decapstudio.com";
    	if (document.select2.more2.options[2].selected) parent.location.href = "http://www.dubtastic.com";
    	if (document.select2.more2.options[3].selected) parent.location.href = "http://snoogie.de.vu";
    	if (document.select2.more2.options[4].selected) parent.location.href = "http://www.steeldolphin.com";
    
    }
    I would prefer that the jscript was a seperate file from the shtml doc.

    Thanks in advance, and if it means anything, I will give mad props to whoever helps me figure this out.

  2. #2
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: need help making a jscript

    To get your link to open in the iframe, you have to target the iframe's src property. Here's a function I use to do that (only works in v5+ browsers):
    Code:
    function openPage(elm, theURL) {
        temp = document.getElementById(elm);
        temp.src = theURL;
    }
    Then you just call the function with the URL of the page you want opened in the iframe like so:
    Code:
    if (something is selected) {
        openPage(elementID, "somepage.asp");
    }
    To open your other links in a new window is pretty easy. Make a function to open the window, and call that function sending the URL as an argument:
    Code:
    if (something else is selected) {
        popup("http://www.some-url.com");
    }
    function popup(url) {
        var newWin=window.open(url);
    }
    Rob Nolan
    Do or do not, there is no try.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •