Jump to content
  • entries
    2
  • comments
    4
  • views
    204

Alert Box


swydell

174 views

Using Windows in Note Pad I typed out Java Script instructions for showing an alert box in a browser. It works. But when I copied the exact instructions and placed it in the Text Editor on my Mac Book Pro I cannot get Fire Fox to show the alert box, instead it opens the file. Here is the Java Script script:

<html>

<head>

<script type="text/javascript">

function show_alert()

{

alert("Hello! I am an alert box!");

}

</script>

</head>

<body>

 

<input type="button" onclick="show_alert()" value="Show alert box" />

 

</body>

</html>

 

What am I doing wrong. Please help.

2 Comments


Recommended Comments

bladedanny

Posted

Text editor doesnt save as plain text by default. If you open text edit the click (in the top left) textedit followed by preferences there should be an option in there to select plain text. Select that then try saving your file as filename.html again and see if that works.
vikpaw

Posted

firefox / mac is a lot stricter with the rules, it's most likely the file extension being wrong.

another thing i'd want to avoid is using a built in function in the name of a custom function. i'm sure the underscore prefix is okay but i'd rather call it "show_abox" or something else, it would make it less confusing at a quick glance too.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...