Detecting the Safari Browser to load scripts

I needed to detect if Safari was being used as there were some issues with styling on a website I was working upon, only on Mac Safari though!!!

The following code is what I use to detect safari and load the relevant script:

<script type="text/javascript">

 		//you are using safari, or at least you CLAIM to be
		document.write('<link type="text/css" media="screen" rel="stylesheet" href="/css/safari.css" title="example" />');

Add in the tags and set the path to the correct css file you wish to load. Same concept can be used to load javascript files.

Preparing an master page for print only view – stripping out css etc

Searching google turned up nothing on this so did some digging in MSDN and worked out a method of disabling all the style sheets, javascript etc to produce a text only page:

1/ Add a content block to your master page – i’ve called mine ‘cssContentHolder’

<asp:contentplaceholder id=”cssContentHolder” runat=”server”>
<link rel=”stylesheet” href=”css/master.css” type=”text/css” media=”all” />
<link href=”css/flyout.css” media=”screen” rel=”stylesheet” type=”text/css” />
<script src=”scripts/APIs/JQuery/JQuery-1.3.2.min.js” type=”text/javascript”></script>
<script src=”scripts/APIs/JQuery/Plugins/jquery-ui-1.7.1.custom.min.js” type=”text/javascript”></script>

2/ In the markup, add a link button so the user can click it to remove the formatting

<asp:LinkButton  PostBackUrl=”#” ID=”textLink”  runat=”server” Text=”Text Only Version” onclick=”textLink_Click” ></asp:LinkButton>

3/ In the code behind, create an event handler for the button and add the following code

protected void textLink_Click(object sender, EventArgs e)
bool Hidden = Page.Master.FindControl(“cssContentHolder”).Visible ;
Page.Master.FindControl(“cssContentHolder”).Visible = !Hidden;
if (Hidden)
textLink.Text = “Switch to Graphical Version”;
textLink.Text = “Text Only Version”;

That’s it. When you click on the link, you will perform a postback to the server, get the state of the control and show/hide accordingly. It will also change the text so you can click back again.

Simple when you know how!

Using Javascript, another method to remove all the CSS but not update any link text etc is to call the following function:

function hideCSS(){

Developers issue death warrant for IE6 | News | TechRadar UK

A campaign calling for the immediate death of Internet Explorer 6 is picking up pace, with a host of developers castigating the browser that ‘hindered the development of the web’.

.net magazine is supporting a campaign to rid the world of IE6 – a browser that is still being used by a large proportion of people – asking the industry if the time has come for sites to no longer support IE6.

The magazine – a Future publication just like TechRadar – is hoping that Microsoft will port IE7 and IE8 to Windows 2000 allowing thousands of users to upgrade.


“Clearly, IE7 can’t be shunned: not supporting the current version of Microsoft’s market-leading browser would be a crazy move. However, with its predecessor now approaching its eighth birthday – positively ancient in software terms – should designers now ignore it until it fades away?” asks .net.

“That’s a really attractive thought,” Kleber’s Tom Muller answers, “but when a fifth or more of the audience still uses IE6, we can’t just drop it.”

It’s a valid point, and will be repeated by web designers the world over if they considered dropping support for the notorious IE6, but .net‘s editor Dan Oliver insists that the time has come for the plug to be pulled.

Developers issue death warrant for IE6 | News | TechRadar UK.