SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot MediaOhgr's Avatar
    Join Date
    Jul 2001
    Location
    Calgary, Alberta, Canada
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript Help Please.

    I need someone to help me out here. I'm working on my portfolio page that will have both a shockwave version as well as an HTML version.

    What I've got is a splash page with a logo and 2 buttons. I've got mouseover effects on the buttons (via dreamweaver) and would like to have those buttons trigger 600x400px pop-ups. I've got the dreamweaver code in there then tried to paste some pop-up javascript in there and got an error.

    So what do I do to combine a rollover as well as a javascript pop-up?
    MediaOhgr - But then again, maybe it's just me ...

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whats is the error and show us some code please ...It could be several things
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Zealot MediaOhgr's Avatar
    Join Date
    Jul 2001
    Location
    Calgary, Alberta, Canada
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="html.html" onMouseOut="MM_swapImgRestore()"
    onMouseOver="MM_swapImag
    ('html','','images/button_html2.gif',1)"><img
    name="html" border="0" src="images/button_html.gif"
    width="70" height="67" alt="HTML Version">

    Is my current rollover code, and I'd like to put this in there to create a pop-up window on click:

    <a href="#" onClick="MyWindow=window.open
    ('http://www.carriere.uni.cc/shocked.html','MyWindow',
    toolbar=no,location=no,directories=no,status=no,menubar
    =no,scrollbars=no,resizable=no,width=600,height=400,le
    t=200,top=150'); return false;">

    I know ZERO about JavaScript so I figure I just didn't combine the two together properly.
    Last edited by MediaOhgr; Nov 29, 2001 at 14:14.
    MediaOhgr - But then again, maybe it's just me ...

  4. #4
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have two options. One just looks a little cleaner but both will work.

    Code:
    <a href="javascript:void(0)" onclick="MyWindow=window.open ('http://www.carriere.uni.cc/shocked.html','MyWindow',
     'toolbar=no,location=no,directories=no,status=no,
    menubar=no,scrollbars=no,resizable=no,width=600,height=400,left=200,top=150'); return false;" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImag('html','','images/button_html2.gif',1)"><img
    name="html" border="0" src="images/button_html.gif"
    width="70px" height="67px" alt="HTML Version"></a>
    That should work. Just make sure to have end quotes on everything.

    You could also make it call a function which would be cleaner looking

    put this in the head
    Code:
    function openWin(){
        var MyWindow=window.open ("http://www.carriere.uni.cc/shocked.html","MyWindow", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=400,left=200,top=150"); 
        return false; 
    }
    in the link

    Code:
    a href="javascript:void(0)" onclick="openWin()" onmouseout="MM_swapImgRestore()" 
    onmouseover="MM_swapImag('html','','images/button_html2.gif',1)"><img
    name="html" border="0" src="images/button_html.gif"
    width="70px" height="67px" alt="HTML Version"></a>
    It just looks a read a little cleaner when seperated like that. Hope that helsp
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  5. #5
    SitePoint Zealot MediaOhgr's Avatar
    Join Date
    Jul 2001
    Location
    Calgary, Alberta, Canada
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope. That really messed things up! I tried both methods and no go. It's messes the whole page page up.
    MediaOhgr - But then again, maybe it's just me ...

  6. #6
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by MediaOhgr
    Nope. That really messed things up! I tried both methods and no go. It's messes the whole page page up.
    Strange I use both of those techniques frequently. I even use macromedia and have some of the MM swap codes. Strange maybe someone else can help then

    Cna you post a link or post more of the code so I can take a look. ???
    Last edited by Maelstrom; Nov 29, 2001 at 20:30.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  7. #7
    SitePoint Zealot MediaOhgr's Avatar
    Join Date
    Jul 2001
    Location
    Calgary, Alberta, Canada
    Posts
    189
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Got it!

    Like I said before, I know absolutly nothing about JS so it may have been something I did in my cutting and pasting. What I ended up doing was us an awesome little freeware app called JavaScript Buttons II, a pop-up menu generator at EchoEcho.com then got a buddy of mine who has taken some JavaScript at Uni to have a look and slap the two together. This is the result:

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide from old browsers
    var iName=""; 
    var nav=navigator.appName.indexOf("Netscape"); 
    var vers=parseInt(navigator.appVersion);
    
      if ( (nav != -1 && vers >= 3) || (vers == 4) ) 
      {
    default1 = new Image(); default1.src = "images/button_shocked.gif"
    changed1 = new Image(); changed1.src = "images/button_shocked2.gif"
    default2 = new Image(); default2.src = "images/button_html.gif"
    changed2 = new Image(); changed2.src = "images/button_html2.gif"
      }
      function Ichange(p) 
        {
        if ( (nav != -1 && vers >= 3) || (vers == 4) ) {
        var pSrc=eval(p+ ".src");
        document[iName].src = pSrc;
        }
      }
    // end hiding -->
    </SCRIPT>
    ... for the head ...

    Code:
    <a href="#" onClick="MyWindow=window.open
    ('http://www.carriere.uni.cc/shocked.html','MyWindow',
    toolbar=no,location=no,directories=no,status=no,menuba
    =no,scrollbars=no,resizable=no,width=600,height=400,le
    t=200,top=150'); return false;"
    onMouseOver="iName='image1'; Ichange('changed1')"
    onMouseOut="Ichange('default1')"><img
    src='images/button_shocked.gif' width='67' height='66'
    name='image1' border='0'></a>
    ... for the links ...

    And there it is!
    MediaOhgr - But then again, maybe it's just me ...

  8. #8
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    ech Ech ECH!

    Ergh... I don't have time to teach you the 20 things you've done wrong already becuase I'm about to go into a meeting, but pm me if you want "proper" code for this...
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  9. #9
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It wasn't as bad as I thought, I just needed to encapsulate the window opening script (from http://www.studiococo.com/custom.asp?window.asp)

    Code:
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide from old browsers
    var iName=""; 
    var nav=navigator.appName.indexOf("Netscape"); 
    var vers=parseInt(navigator.appVersion);
    
    if ( (nav != -1 && vers >= 3) || (vers == 4) ) 
    {
    	default1 = new Image(); default1.src = "images/button_shocked.gif"
    	changed1 = new Image(); changed1.src = "images/button_shocked2.gif"
    	default2 = new Image(); default2.src = "images/button_html.gif"
    	changed2 = new Image(); changed2.src = "images/button_html2.gif"
    }
    
    function Ichange(p) 
    {
    	if ( (nav != -1 && vers >= 3) || (vers == 4) ) 
    	{
    		var pSrc=eval(p+ ".src");
    		document[iName].src = pSrc;
    	}
    
    }
    
    function SC_openWin(loc,width,height)
    {
    	var newwin=window.open(loc,'newwin','width=' + width + ',height=' + height + ',top=10,left=10,menu=no,toolbar=no,directories=no,status=no,scrollbars=no,,dependent=no');
    } 
    
    // end hiding -->
    </SCRIPT>
    </head>
    
    <body>
    <a href="#" onClick="SC_openWin('http://www.carriere.uni.cc/shocked.html',600,400)"
    onMouseOver="iName='image1'; Ichange('changed1')" onMouseOut="Ichange('default1')">
    <img src='images/button_shocked.gif' width='67' height='66' name='image1' border='0'></a>
    
    </body>
    </html>
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright


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
  •