www.webdeveloper.com
Results 1 to 9 of 9

Thread: Auto jump HTML script

  1. #1
    Join Date
    Mar 2012
    Posts
    4

    Auto jump HTML script

    I am using a html script for a popup window, but I want to add a script to auto jump down when the popup loads to a specified part on the page - mainly to bypass my header logo etc. How do I go about doing this?

    Thanks
    Nick

  2. #2
    Join Date
    Feb 2011
    Location
    Chuluota, Florida
    Posts
    144
    well in html you can set id's on the page that let you name them and jump to them with
    Code:
    <a href="#somename"></a>
    but Im not exactly sure how you have your code so I cant be too much of a help when it comes to actually how to edit what you have to include this.

  3. #3
    Join Date
    Mar 2012
    Posts
    4
    I'm using the script from Dynamic Drive

  4. #4
    Join Date
    Feb 2011
    Location
    Chuluota, Florida
    Posts
    144
    Alright let me play around with it for a minute

  5. #5
    Join Date
    Feb 2011
    Location
    Chuluota, Florida
    Posts
    144
    Ok I got it, its actually pretty simple. I will demonstrate it using my website for you.


    Make a blank html file and copy this code into it. Then run it in the browser.
    Code:
    <html>
    <head>
    <script language="javascript" type="text/javascript">
    <!--
    /****************************************************
         Author: Eric King
         Url: http://redrival.com/eak/index.shtml
         This script is free to use as long as this info is left in
         Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
    ****************************************************/
    var win=null;
    function NewWindow(mypage,myname,w,h,scroll,pos){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
    settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
    win=window.open(mypage,myname,settings);}
    // -->
    </script>
    </head>
    <body>
    <a href="http://www.jmcanineservices.com/training.php#puppy" onclick="NewWindow(this.href,'mywin','500','600','no','center');return false" onfocus="this.blur()">YourLinkText</a>
    </body>
    </html>
    Now if you notice that when you open the window it jumps automatically to the puppy section of the website I built. This is achieved by adding a div tag with an id name surrounding the info i want to jump to. So by doing this youll notice that I added into the URL of the link the #puppy part. This tells it to automatically to go to that div on the page.

    Code:
    <a href="http://www.jmcanineservices.com/training.php#puppy"
    <!-- You will see that I added this div tag id into the URL-->
    Code:
    <div id="puppy">Content goes here that you want to jump too</div>
    Hope that is what you were looking for
    Here is the page on the site i sent you too so you can see how far down it takes you
    http://www.jmcanineservices.com/training.php
    Last edited by PBSWebDesign; 03-06-2012 at 06:40 PM.

  6. #6
    Join Date
    Mar 2012
    Posts
    4
    Hi,

    thanks for the code - I opened your site in IE7 and Mozilla 10 and it didn't jump down - not sure if my browser is not reading the code right maybe?

  7. #7
    Join Date
    Feb 2011
    Location
    Chuluota, Florida
    Posts
    144
    Works for me in IE and Firefox. I will post the file that I used. Click the text link and it will open the popup and take you down the page.

    Just extract the one little file and then run it in Firefox or IE. Then a text link will pop up on the page and you click that. it will take you to the page jumped down about halfway.
    Attached Files Attached Files

  8. #8
    Join Date
    Mar 2012
    Posts
    4
    oh ok, its working now - thanks a bunch for your help - its working beautifully.

    Nick

  9. #9
    Join Date
    Feb 2011
    Location
    Chuluota, Florida
    Posts
    144
    Your welcome. If you need anything else dont hesitate to ask You can also PM me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles