I have a .js
file which i include like:
<script src="<?php echo $Settings_PathName; ?>/includes/jquery/jquery.js" type="text/javascript"></script>
inside this file is just normal Javascript codes and functions however it stops my <title>
tag from displaying the page title in the browser window.
As soon as i remove this link, the browser title works fine.
i have also tried removing the code from this .js
file and uploading it to the website, but it still causes the same issue
I have a .js
file which i include like:
<script src="<?php echo $Settings_PathName; ?>/includes/jquery/jquery.js" type="text/javascript"></script>
inside this file is just normal Javascript codes and functions however it stops my <title>
tag from displaying the page title in the browser window.
As soon as i remove this link, the browser title works fine.
i have also tried removing the code from this .js
file and uploading it to the website, but it still causes the same issue
- Does the page content after title is loaded ? – Mteuahasan Commented Aug 6, 2015 at 9:20
- 7 What does the script tag look like on the output page? (after php rendered) – Andy Newman Commented Aug 6, 2015 at 9:26
-
2
That's an odd behavior, can you share some more code? Perhaps the contents inside
<head></head>
after PHP has executed? – Marcos Dimitrio Commented Aug 9, 2015 at 21:12 - 4 show us your js file!! if you dont want, at least replace that php script with your static location to isolate the problem. – Ziv Weissman Commented Aug 9, 2015 at 21:38
- 1 I am sure there is some problems with generated html. Without seeing your page nobody can help. – Gennady Dogaev Commented Aug 14, 2015 at 16:21
4 Answers
Reset to default 9 +50Your html seems good, it's probably an PHP error. If the echo doesn't work, your element can be broken...
first, check your html, it should look like:
<html>
<head>
<title>My Page</title>
<script type="text/javascript" src="<?php echo $Settings_PathName; ?>/includes/jquery/jquery.js"></script>
</head>
<body>
<h1>hello world</h1>
</body>
</html>
In your browser, open the dev tools (press f12 key). In the network panel, you should find your js file in HTTP Status = 200 or 304. If the status = 404 or 500, the script url is wrong.
Else, open the page source (ctl+u) and check the HTML source code write by the php server.
Otherwise, check your php server:
remove the element and replace <h1>hello world</h1>
by <h1><?php echo "hello world"; ?></h1>
If it doesn't work, open your server error log and try to find the issue.
Another simple solution, replace your path by a CDN path :
<script type="text/javascript" src="https://code.jquery./jquery-2.1.4.min.js"></script>
With a CDN you can increase your page loading speed.
I don't think the php is causing the error or else you would have seen an error page stating that your variable is undefined or something similar, and if the value of this variable is empty, your js file won't load, but it won't cause the title to stop working.
It's a wild guess without really seeing the code, but try these things:
1- make sure your title tag is closed properly
2- make sure the script is AFTER the title closing tag inside the head tag
3- if that still didn't work, and if the js
file doesn't necessarily required pre-render, put the script tag immediately before </body>
tag this should stop that behaviour from happening.
I hope this helps
Move your .js file out of the folder and Try following code :
<html>
<head>
<title>Hello</title>
<script type ="text/javascript" src="<?php echo $Settings_PathName; ?>/includes/jquery.js" type="text/javascript"></script>
</head>
<body>
Nothing to display
</body>
</html>
A lot of the ideas here can help, but let's start really simple. On strange behavior of generated code I tend to use "view source" to look at EXACTLY what is being generated. "Inspect element" may work as well. For extra big and plex code I can copy/paste it into a file to pass to an HTML validation service.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744413287a4572988.html
评论列表(0条)