Web Analytics Made Easy -
StatCounter Pop-Up window script, how can use in other script file - CodingForum

Announcement

Collapse
No announcement yet.

Pop-Up window script, how can use in other script file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pop-Up window script, how can use in other script file

    Thanks in advance for your time.
    I use this code to open pop-up windows and want to learn how to use it in other .js files.
    POP-UP:
    function PopUp(PopUpUrl,xW,xH){
    var ScreenWidth=window.screen.width;
    var ScreenHeight=window.screen.height;
    var movefromedge=0;
    placementx=(ScreenWidth/2)-((xW)/2);
    placementy=(ScreenHeight/2)-((xH+50)/2);
    WinPop=window.open(PopUpUrl,"","width="+xW+",height="+xH+",toolbar=0,location=0,directories=0,status =1,scrollbars=1,menubar=0,resizable=1,left="+placementx+",top="+placementy+",screenX=" +placementx+",screenY="+placementy+",");
    }
    I utilize it externally; popup.js. Using as such:
    <a href="javascript:PopUp('somefile.htm','300','280')">

    Then I have other .js files where I would like to use it, like for the footers on most of my pages; footer.js:
    document.write('<P><a href="email.htm" target="_blank">click for PC help</a>');

    What I would like to have is the email.htm file in footer.js to open utilizing the pop-up code.
    I imagine using php is best. I would like to continue they way I'm currently running it but am willing to learn a different way.
    Thanks again!

  • #2
    You should use the code like this, so that even if javascript is disabled, the page will still be opened.

    <a href="somefile.htm" onclick="PopUp(this.href,'300','280');return false">somefile</a>

    although in the footer.js, the technique will be useless since the link is generated using document.write but it's a good practice to use.

    document.write('<P><a href="email.htm" onclick="PopUp(this.href,'300','280');return false">click for PC help</a>');
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      OnClick issue now

      Thank you very much for your help I like the approach and am going to apply it to all the pop-ups on the site. I had an onclick alert with some of the pop ups I use letting people know that pop-up stopper programs will prevent windows from opening. This is a Little League baseball site and I really have to dummy down things because of the enduser base and I'm not talking about the kids either. I really don't want to do an onload alert for that page. But maybe the onclick isn't affected as a javascript command would be in those programs?
      The footer issue is what I really wanted to tackle as I want to incorporate it for the left navigation on the site and being able to have the pop-up window function is the key.
      Thanks again

      Comment

      Working...
      X