How do I create a pop up box when someone click on a text or link?

Discussion in 'HTML & Website Design' started by secretsau, May 8, 2010.

  1. #1
    Hi everyone,

    I want to know how do I create a pop up box when some clicks on a text or link..

    for example: Click here.. for our opening hours

    Where it says "click here" I want a small box to appear to show opening hours when its been clicked..

    Thanks :)
    Best Regards
     
    secretsau, May 8, 2010 IP
  2. Lam3r

    Lam3r Active Member

    Messages:
    235
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Look into the Javascript "alert" function
     
    Lam3r, May 8, 2010 IP
  3. Stealth777

    Stealth777 Peon

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I believe you are talking about a link that opens a page in a separate pop-up window, if so this should work:

    <script type="text/javascript">
    var openwindow;
    
    function popupWindow(url)
    {	
    	popup = window.open(url,'name','height=200,width=500');
    	if(window.focus) {popup.focus()}
    }
    </script>
    
    <html>
    <head>
    <title>My Page</title>
    </head>
    <body>
    <a href="javascript:popupWindow('myfile.html');">Link</a>
    </body>
    </html>
    Code (markup):
    Replace myfile.html with the source file you want to display, and just adjust the height and width.
     
    Stealth777, May 8, 2010 IP
  4. MervinJ

    MervinJ Peon

    Messages:
    60
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you sure you want a popup?, Possibly blocked by browsers, If people want to print your opening times there is no menu bar, harder for SEO to find. etc etc

    Just a thought.
     
    MervinJ, May 9, 2010 IP
  5. dezigncore

    dezigncore Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Or you can you jquery for stylish popups ...
     
    dezigncore, May 11, 2010 IP
  6. AtSeaDesign

    AtSeaDesign Active Member

    Messages:
    172
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    93
    #6
    I use nyromodal for most of my smooth box stuff. If you want a simple alert that would work. Very old school but simple.

    Stealth has the other option. You can also add menubar, toolbar, etc to make it behave like a true browser window.
     
    AtSeaDesign, May 11, 2010 IP