• 0

Simple javascript pop-up


Question

Any idea how to make an javascript popup? I already added the code from below but whenever I click the links it opens the same page (demo.html):

<script type="text/javascript">

function popup(){

cuteLittleWindow = window.open("demo.html", "littleWindow", "location=no,width=614,height=222");

}</script>

<center>

<font face="Verdana"><font size="-1"><b><a href="http://www.mywebsite.com/"><font color="#000000">Home Page</font></a> | <a href="javascript:popup()">Demo</a> | <a href="javascript:popup()">Contact</a></b></font></font>

</center>

..and it looks like this:

DG6VE.png

What I'm doing wrong? Cause I know it's pretty simple but I'm not good a html. Thanks.

Link to comment
https://www.neowin.net/forum/topic/1120482-simple-javascript-pop-up/
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Well, it works for me in Chrome, Firefox and IE 10. Normally I would say when you use the "javascript:xxx()" form in an href, to terminate it with a semi-colon ("javascript:xxxxx();")... but rules aren't very strict anymore and that seems to work in recent browsers. Is the window opening behind your browser? Do you have popups disabled or some other security setting enabled?

  • 0

Yes, there are no errors and there's not any other Javascript code apart from that. It's a pretty simple page, nothing complex.

The window opens as it should in the front. Maybe I didn't explained well the problem. The script is working but what doesn't work is this:

1. I have 3 menus: HOME | DEMO | CONTACT (so 3 pages) INDEX.html - DEMO.html and CONTACT.html

2. The javascript resides on the INDEX.html

3. If I click on DEMO it opens the DEMO.html as it should in the front of my browser.

4. But if I click on CONTACT it opens the same DEMO.html and not CONTACT.html

  • 0

I'm not really sure what you're asking, but if you want your links to open a new window, the "name" parameter needs to be: name="_blank". The value "littleWindow" will always point to the same window with every click. "_blank" will spawn a new window/tab with every click.

  • 0

Yes, there are no errors and there's not any other Javascript code apart from that. It's a pretty simple page, nothing complex.

The window opens as it should in the front. Maybe I didn't explained well the problem. The script is working but what doesn't work is this:

1. I have 3 menus: HOME | DEMO | CONTACT (so 3 pages) INDEX.html - DEMO.html and CONTACT.html

2. The javascript resides on the INDEX.html

3. If I click on DEMO it opens the DEMO.html as it should in the front of my browser.

4. But if I click on CONTACT it opens the same DEMO.html and not CONTACT.html

Ohhhhhhh! :) Yes, I very much misunderstood your question/problem. Use target="_blank", pass the page name as a parameter or use a separate javascript function, and also NAME the window dynamically in the open function.

  • 0

This was my little version to test yours...

<script type="text/javascript">

var aPage = new Array();

var aHandle = new Array();

aPage[0] = "somepage.html";

aPage[1] = "someotherpage.html";

aHandle[0] = null;

aHandle[1] = null;

function popupbyidx(idx) {

var prefix = "winname_";

aHandle[idx] = window.open(aPage[idx], prefix + idx, "location=no,width=614,height=222");

}

function closebyidx(idx) {

aHandle[idx].close();

}

function popup(page){

cuteLittleWindow = window.open("demo.html", "littleWindow", "location=no,width=614,height=222");

}</script>

<center>

<font face="Verdana"><font size="-1"><b><a href="http://www.mywebsite.com/"><font color="#000000">Home Page</font></a> | <a href="javascript:popupbyidx(0);">Demo</a> | <a href="javascript:popupbyidx(1);">Contact</a></b></font></font>

</center>

<center>

<font face="Verdana"><font size="-1"><b><a href="http://www.mywebsite.com/"><font color="#000000">Home Page</font></a> | <a href="javascript:closebyidx(0)">Close Demo</a> | <a href="javascript:closebyidx(0)">Close Contact</a></b></font></font>

</center>

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Movavi Video Editor Plus 26.17.0 by Razvan Serea With Movavi Video Editor Plus, you can either enhance your video files with two or three simple steps, or turn them into something completely new. Create your own movies using multiple filters, transitions, and special effects: show multiple videos on one screen with the Picture in picture effect or change the background with the Chroma Key effect, imitate the camera zoom or make your video look like an old-style movie. Adjust video parameters such as brightness, contrast and colors. Stabilize shaky footage, improve video quality and remove defects. Create video presentations, tutorials or educational videos: add titles and record your own narration to create a video with voiceover. Import video from any source: TV-tuner, webcam, camcorder, or VHS. Drop multiple media files onto a timeline and let your imagination do the rest! Features at a glance: Video and audio editing on a timeline Edit, enhance videos Add background music Apply titles and effects Image quality improvement Hollywood-worthy effects High-grade titles and fades Digitize VHS tapes, record video from TV tuners Stabilize any shaky sections Support for a wide range of formats Prepare your videos for uploading to YouTube, Facebook, Vimeo, or any other website New in Movavi Video Editor 2026: 30+ fresh subtitle styles. Upgrade your automatic captions with new designs. Customize your text in the Styles tab with a single click. Optional advanced settings are also available in the dedicated Design tab. Subtitles in English – instantly! Translate auto-subtitles into English with a click – no dictionaries or online services needed. Once translated, configure and fine-tune the subtitles using the standard editing tools. 40+ adjustable effects. Enhance your videos in a click with new realistic effects – from dust particles and light leaks to retro-style and VHS. Every effect is fully customizable – so it will fit any clip perfectly and bring an extra spark to your edits. Ultra-fast playback. Show more in less time with video speed control of up to 100x. Perfect for epic time-lapses, long process recaps, or whenever you want to add some extra energy to your content. Magnetic zones are marked with dots, and the 1x value is indicated by a vertical line. Silence removal – in a click. Cut out unwanted pauses automatically or fine-tune the pause length and volume threshold yourself. Skip the tedious cleanup and make your videos more dynamic. Fast effect copying. Effortlessly duplicate any effect from one video to another: click Clip effects in the dropdown menu and proceed to copy or paste. Movavi Video Editor Plus 26.17.0 changes: A new set of subtitle styles Check out the latest drop of ready-made subtitle styles with active word highlighting – fully designed and ready to use. Each one has its own vibe, so you can quickly find the perfect match for your video. Give them a spin and pick your favorite. Download: Movavi Video Editor Plus 26.17.0 | 2.7 MB (Shareware) View: Movavi Video Editor Plus Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • "New" Outlook has themes and colours and all sorts of visual customizations not just black and white.
    • What a bizarre statement. Why are you against users having choices? Are you against all extensions or just ad blocking? What about extensions to alter the W11 start menu to suit user preferences. Are you against those?
    • Honestly, I've been using the Lite version for a couple of months now, and it's been working well for me in my daily life. So much that I don't even miss the original version.
    • I use classic for reliability. Dark grey is vastly better than the all black or all white of new outlook.
  • Recent Achievements

    • Week One Done
      skylerssviv earned a badge
      Week One Done
    • One Month Later
      mobmobiles earned a badge
      One Month Later
    • Very Popular
      Captain_Eric earned a badge
      Very Popular
    • One Month Later
      amusc earned a badge
      One Month Later
    • One Month Later
      DJC50PLUS earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      501
    2. 2
      PsYcHoKiLLa
      230
    3. 3
      +Edouard
      98
    4. 4
      ATLien_0
      91
    5. 5
      Steven P.
      82
  • Tell a friend

    Love Neowin? Tell a friend!