IE not loading properly only the first time - php

I have an application that works perfectly in Chrome,Firefox and Safari, but when I load it on IE happens a strange thing: all the page is loaded on the left side and after one or two refresh it loads properly.
Here are two descriptive images:
And the second time (after one or more refresh) IE loads it like this:
Does anyone know why is IE having this behaviour?
Thank you.

I found the problem, it was quite simple.
I was calling my 'functions.php' as the very first code line (even before <!DOCTYPE html...). This file includes some javascripts function that CAN'T be loaded before <!DOCTYPE html (better between <head></head> tags).
Once I placed them between <head> tags the page is loading properly.
Thank you for the hints.

Related

HTML render issue - works in Mozilla Firefox, but not on Google Chrome

The following Php file renders perfectly fine with Mozilla Firefox. However, when running the same on Google Chrome; result - It displays the entire HTML code instead of rendering it. Basically indicates that Google Chrome browser is unable to understand and display the HTML code.
abc.php File
<?php
session_start();//session is a way to store information (in variables) to be used across multiple pages.
?>
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.3.js"></script>
.... //some lines of code
</html>
Problem was
While Firefox browser parses and renders the HTML code.
Google Chrome isn't able to understand that the php file is a HTML code in itself.
Solution
Placement of the DOCTYPE line as the FIRST LINE of the FILE
Hence the change is in the positioning of the DOCTYPE line indicating the type of document to be displayed on the browser.
abc.php File
<!DOCTYPE html>
<?php
session_start();//session is a way to store information (in variables) to be used across multiple pages.
?>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.3.js"></script>
.... //some lines of code
</html>

codeigniter letter at start of every page

I'm working on a website, which I have temporarily hosted here.
You'll notice the mystery letter 'a' I'm getting at the start of every page. I've gone through all the php files (controllers, views, models) and cannot locate where this letter is coming from. Another curiosity is that all the head content is not residing in the head tags when inspected with Firebug. It appears in the body tags, however it still functions correctly. Are these two issues related?
The only thing I have found from searching the internet is that perhaps some files have been saved as ANSI instead of UTF-8. I've tried 'saving as' all my php files as UTF-8 using my editor, but it is a very slow process. Any help debugging this situation would be appreciated.
EDIT- thanks for your response, #erman-belegu. It doesn't seem to be in any controller. For instance, I've set up a 404 redirect, with its own controller and view. The view looks like this:
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="No Page">
</head>
<body>
<h1>No page dude.</h1>
</body>
</html>
But when inspected with firebug, it looks like this:
<html>
<head></head>
<body>
a
<meta content="No Page" name="description">
<h1>No page dude.</h1>
</body>
</html>
I have encoded everything using UTFCast, and am still experiencing the same issue. Any help welcomed.
You see the head inside the body tag because the mysterious "a" is the first character of your output. It's put inside the body tag by the rendering engine of your browser, or by firebug.
If you find the cause of your "a" - almost certainly some content outside PHP tags - the head will return to normal in firebug.
Searching for the "a" is tricky.. I'm not sure how large your codebase is, but I'd say start by exiting the process right before output is sent. You should see only the "a". Then move the exit step by step untill your "a" disappears, and you'll find it.
Check your controllers at start or maybe any print somewhere. Check all your code on these pages because you print these "a ".
Also use UTF-8 without BOM. But, I think that you print it accidentally and dont think that this happens for any other reasons.

Send IE 7 (and below) to old/sub directory of site. <!-- [if IE 7]><"LINK TO OLD SITE"/><![endif]-->

I have just launched a site (using Joomla and a custom template), which doesn't display that well in IE7 (and I guess below too). I have looked around and have found out that you can link to different style sheets from my index.php, however, instead of linking to a different style sheet, I want it to link to the older site which is still live (under www.mydomain.com/old).
Is that at all possible?
As stated in the title, I have looked around and found out that you could use an if statement like this -
<!-- [if lte IE 7]><"LINK TO OLD SITE"/><![endif]-->
is what I'm trying even possible? I haven't got anywhere with it so far, trying the usual html tags of href="http://www.mydomain.com/old"
Any help would be great on this. I'm just getting stuck at the moment!
Conditional comments are used in the client-side part of your page, and so are not useful for PHP. You can use a conditional comment with JavaScript like this:
<!— [if lte IE 7]>
<script type="text/javascript">
top.location.href = "http://www.mydomain.com/old";
</script>
<![endif]-->
The disadvantage of this is that you are performing this task on the client machine, which is slower than if you performed the redirect on the server and sent to user to a different page instead. You can do this using PHP by checking the browser version and redirecting with header:
$browser = get_browser();
if($browser->browser == 'IE' && $browser->majorver <= 7) {
header('Location: http://www.mydomain.com/old');
}
Bear in mind that for this to work you must call header before any data is sent to the client.
Well, much reasonable would be to catch IE7 users before they started to render the page.
So it could be done with server-side script either with some mod_rewrite. Would be easier and faster.
I used Google to find this.
The objective of this technique is to enable redirects on the client side without confusing the user.
...
In HTML and XHTML, one can use the meta element with the value of the http-equiv attribute set to "Refresh" and the value of the content attribute set to "0" (meaning zero seconds), followed by the URI that the browser should request.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The Tudors</title>
<meta http-equiv="refresh" content="0;URL='http://thetudors.example.com/'" />
</head>
<body>
<p>This page has moved to a <a href="http://thetudors.example.com/">
theTudors.example.com</a>.</p>
</body>
</html>

Multibrowser refresh/reload page

I was using this code to reload the page, however I'd only tested it on Chrome and when I tried it on Firefox I realized it didn't work. How do I make it work in other browsers?
echo 'Reloading. <META HTTP-EQUIV="refresh" CONTENT="0">';
Thanks
Instead of pushing out invalid HTML, instead, send the actual header using PHP's header function.
header("Location: http://where.you/want/to/redirect.to");
If the page has already loaded (even partially), then this approach will not work -- in that case, either using JavaScript or the <meta> tag will do the trick -- just remember that the <meta> tag must be added to the <head> portion of your HTML file.
<script type="text/javascript">window.location.reload(true);</script>
What you are doing is telling the browser to refresh. However, the <meta> tag you are using is meant to be in the <head> part of the document. That is probably why Firefox isn't properly executing it.
If you instead use the blurb above, which is javascript, you can put that code virtually anywhere in the document and it will cause the page to refresh.
My guess is that it's not working because it's not in the <head> tag. Generate a properly formatted HTML document and it should work. But why in the world would you want to refresh the page after zero seconds?

Modernizr With Codeigniter

I am having difficulty trying to get modernizer to run with codeigniter.
this is what I've done so far.
downloaded Modernizr and renamed the file modernizr-1.5.min.txt to modernizr-1.5.min.js
put the JavaScript file in the same directory as my header file is: apppath/views/tops/
included the file in my headings <script src="modernizr-1.5.min.js"></script>
included this in my HTML element <html class="no-js">
just to preserve my sanity I put the JavaScript file modernizr-1.5.min.js in my views directory and in the application directory.
I am getting absolutely zero response when I read my page source to see if the has been replaced with the elements that my browser covers the wave modernizr is supposed to work. I have tried this using Firefox and chrome as far as reading the source.
any suggestions? Thank you in advance
why would you put javascript files ito the view folder of your app? i would rather use this path "/media/javascripts/modernizr.js" and then <script src="/media/javascripts/modernizr.js"></script> link it like that. the view folder is only for templates. other thing is that you will never see the changes that javascript does to your page in the pagesource. because it only shows you what html the browser received. and javascript starts to work after the browser received the html. you need to install firebug to see the "live" dom.

Categories