I set an icon like that:
<link rel="icon" type="image/x-icon" href="/media/icon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/media/icon.ico">
and I also tried this:
<link href="/media/icon.ico" rel="shortcut icon" type="image/x-icon" />
It works only in some parts of my website, but I don't know what I'm doing wrong. Is there something that I have to consider?
I use PHP and HTML. I don't know if it's coincidence or not, but it works with every HTML file and only with some of the PHP files.
Can anybody help me?
shivan
You'll need to make sure the URL (href) is valid for the page you are viewing.
Remember / is site level (/media/icon.ico = http://yourdomain.com/media/icon.ico).
Also make sure it is a valid .ico file. I recommend trying a .jpg file instead. (.png, .jpg, .gif and .ico are all valid favicon formats)
As well, depending on the icon size, it may not work in all browsers.
16x16 is the recommend size for favicons, but 32x32 may work as well.
Here is a link that should tell you everything about favicons: http://perishablepress.com/everything-you-ever-wanted-to-know-about-favicons/
If it only appears for your html pages and not your php ones, then you may be adding the link tag incorrectly or it may also be missing.
I suggest you use the developer tools of your browser (right-click anywhere on your page and choose Inspect Element - Chrome, Firefox) when you're on your php pages and check if you see the tag added correctly having the exact same path set there as in your html pages. Using developer tools you should also be able to hover over the link and it would tell you if the image existed or not.
I bet the path will be incorrect somehow depending on the placement of your php files versus the html ones and the icon.
Try accessing those pages from another browser. Also, try accessing them from a browser in incognito/private mode.
If you do see the favicon, try cleaning your browser's cache - it could be that something is left over from the last time you browse those pages (i.e. before you added the favicon to the HTML).
I had trouble getting this to work for me without using a direct link.
For example on my site: http://adamgressen.com/
I reference the image with a direct link:
<LINK rel="SHORTCUT ICON" href="http://adamgressen.com/favicon.ico">
You definitely want to clear your cache if you're testing locally because you may not see the changes for a while otherwise.
Related
I have a stylesheet link that looks like below:
<link rel="stylesheet" href="/example/get_page.php?location=bla.css" id="main_ss" />
get_page.php just gets a URL using file_get_contents():
if (isset($_GET['location'])) {
echo file_get_contents('/example/styles/' . $_GET['location']);
}
I can see that the stylesheet file is being fetched properly (for example the text of the file is showing in firebug when I expend the link tag) but for some reason it is ignored by the browser. If I just fetch the CSS file directly of course everything works.
The code can be seen here: www.specman-verification.com/example/bla.html
Any leads? I'm at loss here.
Add the Content-type header like this (do this before you output anything):
header("Content-type: text/css");
Your code is just trying to load the script get_page.php. To load the CSS file you need:
<link rel="stylesheet" type="text/css" href="/example/bla.css" />
(or similar depending on the actual path to your CSS file). In other words the href attribute needs to specify the path to your spreadsheet file, not the HTML page file.
You need to do it the right way. I understand what you're doing here. You need a good mechanism to dynamically load external CSS and have the result display normal html in the browser output.
Follow the instructions on this url: http://www.warpconduit.net/2009/05/12/dynamically-load-css-and-js-files-using-php/
This will at least get you to have a mechanism to load external css file with php dynamically. You're definitely missing steps in your code.
I'm aware that doing so in HTML is as simple as this:
<link rel="icon" href="/favicon.ico" />
However, I have a PHP site, in which:
DirectoryIndex index.php
to direct the user directly to the main page.
I can't seem to find a way to get a browser tab icon.
What have I tried?
I tried to echo HTML inside index.php with the code, which didn't work. I also tried placing the line of code in some other working header HTML from within index.php. Google has nothing... literally.
The image is a .ico, called 'favicon.ico', is in root, and is recognized as a valid ico file.
Any help?
By default, you actually don't need anything in your HTML for a favicon. Simply having a valid favicon.ico in your root should be enough.
Sometimes, when changing favicon you need to clear your browser cache for that site. Also, try accessing the favicon.ico directly: http://example.com/favicon.ico and make sure you can load it.
Here's a good resource about favicons: HTML 5 Favicon - Support?
I just built a sit in Codeigniter, but when I click on a menu item the stylesheet breaks and it displays all of the content broken out on the page.
http://marciabrownproductions.com/
I uploaded it to a test server and all the links works perfectly.But when I uploaded the finished site ot my clients server the css issue starts. Is there something wrong with my clients server? Or is there a problem with how I coded the site? Why does it work on one server, but not the other.
Thanks!
First, I recommend using absolute paths instead of relative paths when referencing your assets. At the moment, they are being picked up with the index.php included.
So, let's say your link is http://domain.tld/index.php/home/actors, you should be calling your assets from their actual URLs - http://domain.tld/index.php/_/css/style.css would not work, for example. http://domain.tld/_/css/style.css, however, would work. (That's just a sample URL.)
I'd also recommend removing the index.php from your links, simply by using the htaccess RewriteEngine, and removing index.php from your app's config file.
Have a look at how your current source is being generated in a browser (right-click, View Source) to see what I mean.
Update:
Based on your comment, that may be an htaccess issue. Check to see if your hosting provider supports it.
In the meantime, put the index.php back in the app's main config file. However, leave your CSS asset link as it is. Make sure all your asset links look like this:
<link href="http://marciabrownproductions.com/_/css/styles.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='http://marciabrownproductions.com/_/js/jquery.validate.js'></script>
<script type='text/javascript' src='http://marciabrownproductions.com/_/js/effects.js'></script>
<link href="http://marciabrownproductions.com/_/css/bjqs.css" rel="stylesheet" type="text/css" media="screen" />
<script src="http://marciabrownproductions.com/_/js/bjqs-1.3.js"></script>
Your images are broken because their links are also including the index.php/home. You need to make sure that that is taken out. (What are you using to generate your links anyway?)
I have a option in my Wordpress theme options panel that I made to choose from five different styles. Running Wordpress on localhost if I choose yellow, red, green, blue or black the style is applied correctly and everything works fine. The code I'm using in header.php is this:
<link rel="stylesheet" type="text/css" media="screen"
href="<?php bloginfo('template_directory'); ?>/css/<?php echo get_option('of_cssstyles'); ?>.css" />
But when I install the same theme on the web I get a webpage with absolutly no CSS style, you can see it here: (http://macoverflow.org/p3dra/), as you can see no CSS style is beeing applied.
How to fix this?
The stylesheet you are linking to doesn't exist. You need to upload it to the server or link to somewhere it is uploaded.
edit: going to: http://macoverflow.org/p3dra/wp-content/themes/blankfolio/css/ shows that the stylesheet is actually called "yellow.css", but the page you are linking to is "Yellow.css" note the case of the "y".
Did you upload your stylesheets to the server?
Did you set the permissions on the stylesheet to be readable by apache?
I received the following by looking at the final html codein the finished page:
http://macoverflow.org/p3dra/wp-content/themes/blankfolio/css/Yellow.css
This is not found.
whats he is saying is the file name is caase sensitive so Yellow.css and yellow.css are two different files in the eyes of the apache, they are as different as having one called yellow.css and he other called pink.css , the detail is in the first letter, being a capital.
site example: http://ec2-107-22-119-73.compute-1.amazonaws.com/index.php/info/databases
Working Example: http://jscrollpane.kelvinluck.com/mwheel_intent.html
I cant get scrollwheel to work.
If you cant tell from the URL, my site is an expressionengine site. Using coldfusion and junk like that to build the pages.
anyone? (I tried searching for this issue, but no one seems to simply not be able to make scroll work.)
Ensure the paths to your JavaScript/CSS files are named appropriately and aren't throwing 404 errors.
The easiest way to ensure valid links to your assets is to use the {site_url} single global variable when linking assets in your templates:
<script src="{site_url}/script/jquery.mousewheel.js"></script>
<script src="{site_url}/script/jquery.jscrollpane.min.js"></script>
Which would result in the following:
<script src="http://example.com/script/jquery.mousewheel.js"></script>
<script src="http://example.com/script/jquery.jscrollpane.min.js"></script>
Since you're using ExpressionEngine's templates for your CSS — as opposed to flat files — you may want to give those template names a .css file extension.
So instead of:
<link rel="stylesheet" href="/index.php?css=site/master.v.1324329515" />
You'd have:
<link rel="stylesheet" href="/index.php?css=site/master.css.v.1324329515" />
This isn't absolutely necessary since EE will set the proper text/css MIME type based on the template type. However, it does make reading and debugging the source code easier, and is more of a standard practice.
Understandably, many beginners reference and borrow code from the Agile Records ExpressionEngine Theme that's available during new EE installations, so it's easy to recognize EllisLab's approach to markup and architecture — be it for the better or worse.
Bonus: remove the cache-busting timestamp (v.1324329515) in ExpressionEngine from CSS URLs, use the {path} variable instead of the {stylesheet} variable:
// With Cache-Busting String Appended
// http://example.com/index.php?css=site/master.css.v.1324329515"
<link rel="stylesheet" href="{stylesheet=site/master}" />
// Without Cache-Busting String
// http://example.com/index.php/site/master.css
<link rel="stylesheet" href="{path=site/master}" />