2 Replies - 380 Views - Last Post: 03 January 2008 - 10:43 PM

#1 pal121   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-February 06

pop-up

Posted 11 February 2006 - 01:24 PM

Description: copy and paste and change text to what you want it too be!a few different ways of pop-ups
<html>
<head>

<!-- alert box with line break -->
<script type="text/javascript">
function disp_alert()
{
alert("Hello again! This is how we" + 'n' + "add line breaks to an alert box!")
}
</script>

<!-- prompt box -->
<script type="text/javascript">
function disp_prompt()
{
// this is what is in the prompt box
var name=prompt("Please enter your name","")
// no need to edit next line!
if (name!=null && name!="")
{
// this is what is written when ok is pressed
document.write("Hello " + name + "! How are you today?")
}
}
</script>

<!-- confirm box -->
<script type="text/javascript">
function disp_confirm()
{
// this is what comes up in the box
var name=confirm("Press a button")
if (name==true)
{
// this is what is written if you press Ok
document.write("You pressed the OK button!")
}
else
{
// this is what is written if you press Cancel
document.write("You pressed the Cancel button!")
}
}
</script>

<!-- Alert box -->
<script type="text/javascript">
function click_alert()
{
// change text in brackets to what you want it to be!
alert("This is an alert box")
}
</script>

<!-- This is a alert on load of page -->
<script type="text/javascript">
function message()
{
// change text in brackets to what you want it to be!
alert("Pop-up on load!")
}
</script>

<body onload="message()">

<!-- displays alert on click -->
<form>
<!-- change to what you want! -->
<input type="button" onclick="click_alert()" 
value="Click Me!">
</form>



<!-- displays a option box on click -->
<form>
<!-- change yo what you want! -->
<input type="button" onclick="disp_confirm()" 
value="Click Me">
</form>

<!-- displays a prompt box -->
<form>
<!-- change to what you want! -->
<input type="button" onclick="disp_prompt()" value="Display a prompt box">
</form>

<!-- displays an alert box with a line break -->
<form>
<!-- change to what you want! -->
<input type="button" onclick="alert()" value="Alert with break">
</form>

</body>
</html>


Is This A Good Question/Topic? 0
  • +

Replies To: pop-up

#2 HelenChitra   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-December 07

Re: pop-up

Posted 03 January 2008 - 10:24 PM

In line 91, we should call the function disp_alert() onclick. Hence it should be <input type="button" onclick="disp_alert()" value="Alert with break">
Was This Post Helpful? 0
  • +
  • -

#3 HelenChitra   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-December 07

Re: pop-up

Posted 03 January 2008 - 10:43 PM

I'm learning Javascript and this is really helpful. Great.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1