Pawan_Agarwal Posted September 4, 2014 Share Posted September 4, 2014 I have created website and posted it on PHP server BUT, JavaScript is not working ============================================================= <?php error_reporting(E_ALL); date_default_timezone_set('Asia/Kolkata'); ?> <script type="text/javascript" src='images/js1.js'></script> // WHEN I AM TRYING TO IMPORT THE FILE THEN IT IS NOT WORKING <link rel="stylesheet" href="images/mycss.css" type="text/css" /> ============================================================= I have written the above line and the page is not detecting any javascript file ============================================================= <script type="text/javascript" > function display(){ alert("this is text"); } </script> // THIS CODE IS WORKING ============================================================= but if I write, code like this then it is working, can some one tell me why is this happening ?? Quote Link to comment https://forums.phpfreaks.com/topic/290840-javascript-not-working/ Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 what about a css link? Quote Link to comment https://forums.phpfreaks.com/topic/290840-javascript-not-working/#findComment-1489859 Share on other sites More sharing options...
Pawan_Agarwal Posted September 4, 2014 Author Share Posted September 4, 2014 css link is not creating problem, when I try to import JS File , it does not work, but when I write the code in <script> tag and does not import JS File, it works !! Can you suggest something ?? Thanks for your reply ! Quote Link to comment https://forums.phpfreaks.com/topic/290840-javascript-not-working/#findComment-1489879 Share on other sites More sharing options...
cyberRobot Posted September 4, 2014 Share Posted September 4, 2014 Have you tried opening your browser's Console panel to see if there are any page or JavaScript errors? In Chrome, for example, you can hit Ctrl + Shift + J to open the Console. You can also right-click the page and click "Inspect Element" to access the Console. Quote Link to comment https://forums.phpfreaks.com/topic/290840-javascript-not-working/#findComment-1489891 Share on other sites More sharing options...
gristoi Posted September 4, 2014 Share Posted September 4, 2014 can you define 'not working' 1 Quote Link to comment https://forums.phpfreaks.com/topic/290840-javascript-not-working/#findComment-1489892 Share on other sites More sharing options...
Pawan_Agarwal Posted September 4, 2014 Author Share Posted September 4, 2014 when I try to import JS File , no function works, but when I write the code in <script> tag and does not import JS File, function executes !! Can you suggest something ?? Thanks for your reply ! Quote Link to comment https://forums.phpfreaks.com/topic/290840-javascript-not-working/#findComment-1489931 Share on other sites More sharing options...
CroNiX Posted September 4, 2014 Share Posted September 4, 2014 (edited) If your js file ONLY contains function display(){ alert("this is text"); } Then yeah, it does nothing because nothing calls "display()" function. It's just a defined function. To test it, try adding display(); after the function declaration so the function gets called, or just type "display()" in the js console. Edited September 4, 2014 by CroNiX Quote Link to comment https://forums.phpfreaks.com/topic/290840-javascript-not-working/#findComment-1489935 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.