3 Replies - 542 Views - Last Post: 23 January 2013 - 02:36 PM

#1 sisozibit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-January 13

problem with running javascript code on a browser

Posted 19 January 2013 - 08:29 AM

Hello,can someone please tell me how to run javascript on any browser,i have windows 7 and whenever i write a javascript code and run it on a browser,it doesn't seem to work,example,if i type a code for alerting a user whenever he opens the page,the windows dialog box does not appear,i have tried in many ways to sort out this problem but i would really appreciate anyone's help,cheerio!!!
Is This A Good Question/Topic? 0
  • +

Replies To: problem with running javascript code on a browser

#2 exiles.prx  Icon User is offline

  • D.I.C Head

Reputation: 65
  • View blog
  • Posts: 239
  • Joined: 22-November 10

Re: problem with running javascript code on a browser

Posted 19 January 2013 - 09:17 AM

In order for javascript to run, you must place the script tags within the head section or within the body section of your HTML document like so:

<html>
<head>
    <script type="text/javascript">
        $(document).ready(function() {
            alert('head');
        });
    </script>
</head>
<body>
    <script type="text/javascript">
        $(document).ready(function() {
            alert('body');
        });
    </script>
</body>
</html>


As long as the script tags on located within these two sections, the javascript will run on any browser (unless of course the javascript you write is not supported, ex: touchevents on a desktop).
You can also include an external script:
<script type="text/javascript" src="myfile.js"></script>

This post has been edited by exiles.prx: 19 January 2013 - 09:18 AM

Was This Post Helpful? 0
  • +
  • -

#3 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,254
  • Joined: 08-June 10

Re: problem with running javascript code on a browser

Posted 20 January 2013 - 03:33 AM

you might also check, whether Java​Script execution is enabled at all.
Was This Post Helpful? 0
  • +
  • -

#4 JMRKER  Icon User is offline

  • D.I.C Addict

Reputation: 128
  • View blog
  • Posts: 828
  • Joined: 25-October 08

Re: problem with running javascript code on a browser

Posted 23 January 2013 - 02:36 PM

View PostDormilich, on 20 January 2013 - 04:33 AM, said:

you might also check, whether Java​Script execution is enabled at all.


To do that in FF:
1. Click "Firefox"
2. Click on 'Preferences'
3. Choose 'Content' tab
4. Assure 'Enable Javascript' is checked.

In iMac Safari:
1. Click 'Safari'
2. Click 'Preferences'
3. Choose 'Security'
4. Assure 'Enable Javascript' is checked.

In Chrome:
That browser is not available to me at this time. Will add later.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1