Web Analytics Made Easy -
StatCounter can't figure out this pop-up - CodingForum

Announcement

Collapse
No announcement yet.

can't figure out this pop-up

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

  • can't figure out this pop-up

    Howdy,

    I have been struggling with a couple of scripts I found at javascriptkit.

    I simply want a pop-up window but I would like a button instead of a text link that activates the pop-up (like the one they have in their pop-up tutorial)


    <form>
    <input type="button" value="Click here to see">
    onclick="window.open('page2.htm',
    'win1','width=200,height=200')"
    </form>

    But I am also having trouble with the pop-up script that was generated for me with their pop-up wizard.


    <script>

    //Popup Window Script
    //By JavaScript Kit (http://javascriptkit.com)
    //JavaScript tutorials and over 400+ free scripts

    function openpopup(){
    var popurl="venice_beach_sunsetpoll.htm"
    winpops=window.open(venice_beach_sunsetpoll.htm,"","width=400,height=338,scrollbars,resizable,")
    }

    </script>

    <a href="javascriptpenpopup()"><font color="#FFFFFF">Please cast your vote on this photo CLICK HERE</font></a>


    When I preview it in my browser it says "venice_beach_sunsetpoll.htm is undefined"

    Being a cut and paste kinda programmer I don't know what this means.

    Since I am conducting a poll in this pop-up window I want my visitors to view the results in the same pop-up window but is there a way to make the dimensions of the result page different?

    If someone could marry the two scripts above and show me what I am doing wrong overall I would really appreciate it.



    Thank You!
    Last edited by ubtheboss; Jun 18, 2002, 07:10 PM.

  • #2
    Try something like this:


    <script>

    //Popup Window Script
    //By JavaScript Kit (http://javascriptkit.com)
    //JavaScript tutorials and over 400+ free scripts

    function openpopup(){
    var popurl="venice_beach_sunsetpoll.htm"
    winpops=window.open(popurl,"","width=400,height=338,scrollbars,resizable,")
    }

    </script>
    <form>
    <input type="button" value="Click here to see" onclick="openpopup()" >
    </form>


    You had venice_beach_sunsetpoll.htm written out instead of calling the variable that represented it.

    Comment


    • #3
      Thank you John.

      Another question:

      - I want to put two of these scripts on one page. I tried changing the variable 'popurl' of one of them to 'popurl2' but that didn't work.

      ??

      Comment


      • #4
        Try something like this:

        <script>

        //Popup Window Script
        //By JavaScript Kit (http://javascriptkit.com)
        //JavaScript tutorials and over 400+ free scripts

        function openpopup(popurl){
        winpops=window.open(popurl,"","width=400,height=338,scrollbars,resizable,")
        }

        </script>
        <form>
        <input type="button" value="Click here to see" onclick="openpopup('venice_beach_sunsetpoll.htm')" >
        <input type="button" value="Click here to see" onclick="openpopup('a_different_page.htm')" >
        </form>

        this way you pass in the page as a variable

        Comment


        • #5
          Thanks again John.

          That works but the problem is that I need different sized windows for each function/button (one calls up a poll and the other a guestbook sign in form)

          Can you help me with that?

          Cheers!

          Phil

          Comment


          • #6
            Sure just pass those in too:

            <script>

            //Popup Window Script
            //By JavaScript Kit (http://javascriptkit.com)
            //JavaScript tutorials and over 400+ free scripts

            function openpopup(popurl,settings){
            winpops=window.open(popurl,"",settings)
            }

            </script>
            <form>
            <input type="button" value="Click here to see" onclick="openpopup('venice_beach_sunsetpoll.htm','width=400,height=338,scrollbars,resizable,')" >
            <input type="button" value="Click here to see" onclick="openpopup('a_different_page.htm','width=200,height=200')" >
            </form>

            Comment


            • #7
              That works! Once again, thank you.

              One small problem though. For some reason my pop-up windows are starting to pop-up with half of the window half off the screen to the right. I have to click on the top bar of the window and drag it to the left so the whole window is visible on screen.

              What is causing this and is there a cure?

              Cheers!

              Phil

              Comment


              • #8
                Try this popup generator:



                It rocks...

                You can use the code it generates (including centering), and modify it to pass the variables you want into your function...

                Like:

                <script language="javascript" type="text/javascript">
                <!--
                function PopUp(PopUpUrl,thewidth,theheight){
                var ScreenWidth=window.screen.width;
                var ScreenHeight=window.screen.height;
                var movefromedge=0;
                placementx=(ScreenWidth/thewidth)-((thewidth)/2);
                placementy=(ScreenHeight/theheight)-((theheight+50)/2);
                WinPop=window.open(PopUpUrl,"","width="+thewidth+",height="+theheight+",toolbar=0,location=0,directo ries=0,status=0,scrollbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+ placementx+",screenY="+placementy+",");
                }
                // -->
                </script>

                <a href="javascript:PopUp('http://www.barbie.com',400,300)">Barbie</a><br />
                <a href="javascript:PopUp('http://www.yahoo.com',800,600)">Yahoo!</a><br />
                Former ASP Forum Moderator - I'm back!

                If you can teach yourself how to learn, you can learn anything. ;)

                Comment


                • #9
                  Thank you whammy. That is a great tool for creating pop-ups.

                  In my particular case however I really like John's way of creating what I needed with just one set of code and passing on the popurl and the settings.

                  This may be possible with the tool you showed me but I am not a programmer so I wouldn't know how to alter it.

                  So, John I appeal to you again, or someone, who can show me what extra code to add and where to add it in order to stop my two pop-ups from appearing half off the screen.

                  Thanks all.

                  Cheers!

                  Phil

                  Comment


                  • #10
                    Actually I just did... check out the part where it centers the popup on the screen. Have you copied and pasted that and checked it out?
                    Former ASP Forum Moderator - I'm back!

                    If you can teach yourself how to learn, you can learn anything. ;)

                    Comment


                    • #11
                      Yes, I checked out that pop-up generator and clicked the 'preview' button and it was great. If I just wanted one pop-up window then that would have solved everything but if you read through the posts in this thread you'll see that I am trying to open two different pages in two different pop-ups with different window sizes. So far John has helped me get there but now the windows are appearing half off the screen. That's the problem.

                      If you can show me where I can do all of this with the pop-up generator code then sure I'll use that.

                      By the way, surfing around that pop-up window generator site I was assaulted by pop-ups myself PLUS I got a VIRUS warning from my virus protection software. I am now having to sweep my hard drive for others.

                      The pop-ups were annoying but understandable- the site is free.

                      The virus.........???

                      Comment


                      • #12
                        Did you try the modified code that I posted above? It opens two separate popups at two different sizes... and I didn't modify it for my own health...
                        Former ASP Forum Moderator - I'm back!

                        If you can teach yourself how to learn, you can learn anything. ;)

                        Comment


                        • #13
                          Ok. I see what you did. Sorry. Like I said I am not a programmer and barely figure out what all this stuff means.

                          Now to make myself more of a pain, what do I do if I want to use buttons instead of text links for the two pop-ups?

                          Cheers!

                          Comment


                          • #14
                            <input type="button" value="My Button Name!!" onClick="PopUp(whatever)" />

                            Former ASP Forum Moderator - I'm back!

                            If you can teach yourself how to learn, you can learn anything. ;)

                            Comment


                            • #15
                              Ok. Well I tried YOUR modified code. It won't work. Just to show you that I am using the same code as listed above I am going to cut and paste it below straight out of Front Page

                              <script language="javascript" type="text/javascript">
                              <!--
                              function PopUp(PopUpUrl,thewidth,theheight){
                              var ScreenWidth=window.screen.width;
                              var ScreenHeight=window.screen.height;
                              var movefromedge=0;
                              placementx=(ScreenWidth/thewidth)-((thewidth)/2);
                              placementy=(ScreenHeight/theheight)-((theheight+50)/2);
                              WinPop=window.open(PopUpUrl,"","width="+thewidth+",height="+theheight+" ,toolbar=0,location=0,directories=0,status=0,scrol
                              lbars=0,menubar=0,resizable=0,left="+placementx+",top="+placementy+",screenX="+placementx+",screenY= "+placementy+",");
                              }
                              // -->
                              </script>

                              <a href="java script:PopUp('http:/www.barbie.com',400,300)">Barbie</a><br />
                              <a href="java script:PopUp('http:/www.yahoo.com',800,600)">Yahoo!</a><br />





                              No pop-ups appear at all. Instead each click goes to a non-existant page in the full browser page.

                              Now, obviously www.yahoo.com does exist so somewhere there lies a problem. I have no idea. I'm not a programmer.

                              Comment

                              Working...
                              X