Author Topic: Linking with Javascript. Help.  (Read 203 times)

0 Members and 1 Guest are viewing this topic.

Offline iStriideTopic starter

  • Enthusiast
  • Posts: 77
  • Gender: Male
  • Still learning PHP.
    • View Profile
Linking with Javascript. Help.
« on: July 29, 2010, 11:56:47 PM »
I just started javascript, and i was wondering if their was a way that you use the prompt(""); code or document.write or something that will pop with a box like alert but that you can type in a url and click ok and it will take you to that page.

Offline Adam

  • Guru
  • Fanatic
  • *
  • Posts: 4,702
  • Gender: Male
    • View Profile
Re: Linking with Javascript. Help.
« Reply #1 on: July 30, 2010, 04:16:38 AM »
Yeah, pretty easily. The basic code would be something like:

Code: [Select]
var url = prompt('Prompt message here..');

if (url)
{
    window.location = url;
}

You'll most likely want to add in some URL validation though.
Ronnie Wood, true or false?