Browser Recommended

How can I create an alert recommending the use of a specific browser?

Page 1 of 1

8 Replies - 783 Views - Last Post: 17 May 2010 - 07:53 PM

#1 Guest_Ian*


Reputation:

Browser Recommended

Posted 17 May 2010 - 03:21 PM

Hi, I'm an extreme novice to web development but I'm pretty sure what I want to do would best be done in PHP.

Basically what I want to do is make an alert that says "Google Chrome Recommended" that appears on my site across the top if someone not using chrome goes to my site which could then be closed.

So, to explain more clearly. If someone goes to my site not using chrome a message would appear across the top (pushing the rest of the site down) that says "chrome recommended" then they can close it and it would push the site back up (since I don't want a big empty space at the top of my site before the header)

If anyone has any information on how this would be done, or a tutorial on how to achieve things like this, or just the code itself then I would really be very very appreciative. Thank you.

Is This A Good Question/Topic? 0

Replies To: Browser Recommended

#2 moopet  Icon User is offline

  • binary decision maker
  • member icon

Reputation: 339
  • View blog
  • Posts: 1,185
  • Joined: 02-April 09

Re: Browser Recommended

Posted 17 May 2010 - 03:28 PM

View PostIan, on 17 May 2010 - 09:21 PM, said:

Hi, I'm an extreme novice to web development but I'm pretty sure what I want to do would best be done in PHP.

Basically what I want to do is make an alert that says "Google Chrome Recommended" that appears on my site across the top if someone not using chrome goes to my site which could then be closed.

So, to explain more clearly. If someone goes to my site not using chrome a message would appear across the top (pushing the rest of the site down) that says "chrome recommended" then they can close it and it would push the site back up (since I don't want a big empty space at the top of my site before the header)

If anyone has any information on how this would be done, or a tutorial on how to achieve things like this, or just the code itself then I would really be very very appreciative. Thank you.


There are lots of ways to do this. The most obvious being: do it in javascript.
More importantly, I'd suggest "don't do it at all" - if your site only works properly in one particular browser, then your site is broken, and if it works cross-browser, then you should let your visitors make their own choices...
Was This Post Helpful? 1
  • +
  • -

#3 Guest_Ian*


Reputation:

Re: Browser Recommended

Posted 17 May 2010 - 04:24 PM

View Postmoopet, on 17 May 2010 - 02:28 PM, said:

There are lots of ways to do this. The most obvious being: do it in javascript.
More importantly, I'd suggest "don't do it at all" - if your site only works properly in one particular browser, then your site is broken, and if it works cross-browser, then you should let your visitors make their own choices...


My site doesn't work properly in IE (although I'm working on fixing that) it works perfectly in Firefox, Safari, and of course Chrome. However, part of my reason for wanting to recommend Google Chrome is due to their lack of ad blocking, and since I make money off of my ads I would much prefer it if visitors had the ads visible. I want to create it not as an annoying nag, but rather a one-time recommendation that they can select to not have pop up again. However, I do not know how to do this. I imagine it would require the use of cookies or something to memorize who has selected what but I don't know how cookies work because again, I'm a novice. If you think I'd be better off inquiring within the Javascript section then I will do that, thank you.

I will keep checking this post though, so if anyone can give me any help in achieving this (whether you think I should do it or not) then I would very much appreciate it.

Thank you.
Was This Post Helpful? 0

#4 Guest_Ian*


Reputation:

Re: Browser Recommended

Posted 17 May 2010 - 04:43 PM

Hi, I'm an extreme novice to web development and I was told that what I want to do can be done in Javascript

Basically what I want to do is make an alert that says "Google Chrome Recommended" that appears on my site across the top if someone not using Chrome goes to my site. I would also like this to be able to have an option that says "don't show again" which would stop it from popping up the next time someone visits the site. I assume that require the use of cookies but I don't know how those work.

So, to explain more clearly. If someone goes to my site not using chrome a message would appear across the top (pushing the rest of the site down) that says "chrome recommended" then they can close it and it would push the site back up (since I don't want a big empty space at the top of my site before the header)

If anyone has any information on how this would be done, or a tutorial on how to achieve things like this, or just the code itself with an explanation that allows me to tinker with it and figure it out then I would really be very very appreciative. Thank you.
Was This Post Helpful? 0

#5 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1102
  • View blog
  • Posts: 6,909
  • Joined: 07-September 06

Re: Browser Recommended

Posted 17 May 2010 - 04:55 PM

So, basically the first thing you will need to do is come up with a browser detection script (there is a pretty good one here):
http://www.quirksmod.../js/detect.html

Then you need to check and see if the browser is not chrome (It is faster than checking if the prowser is everything else). If it is you could either use a DOM class to modify the document and acc an element to the top of the page, or prepend some HTML to the document body. Once that is done you will need a cookie to remember if they don't want the message displayed again, one can be found here:
http://www.w3schools.../js_cookies.asp

I believe that will allow you to accomplish what you are wanting.

Hope that helps.
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1632
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Browser Recommended

Posted 17 May 2010 - 05:00 PM

Topics merged, please don't create duplicates
Was This Post Helpful? 0
  • +
  • -

#7 Guest_Ian*


Reputation:

Re: Browser Recommended

Posted 17 May 2010 - 05:51 PM

View PostPsychoCoder, on 17 May 2010 - 04:00 PM, said:

Topics merged, please don't create duplicates


Umm, what was I supposed to do? I originally created it in the PHP section and was told it was likely something that should be done in Javascript. So I then created a new one of the same type in the Javascript section... Seriously, what else was I supposed to do? Leave it in the wrong section and not get the answer I'm looking for? I'm logged in as a guest, and therefore can't edit my previous posts or delete them.
Was This Post Helpful? 0

#8 Guest_Ian*


Reputation:

Re: Browser Recommended

Posted 17 May 2010 - 05:57 PM

View PostBetaWar, on 17 May 2010 - 03:55 PM, said:

So, basically the first thing you will need to do is come up with a browser detection script (there is a pretty good one here):
http://www.quirksmod.../js/detect.html

Then you need to check and see if the browser is not chrome (It is faster than checking if the prowser is everything else). If it is you could either use a DOM class to modify the document and acc an element to the top of the page, or prepend some HTML to the document body. Once that is done you will need a cookie to remember if they don't want the message displayed again, one can be found here:
http://www.w3schools.../js_cookies.asp

I believe that will allow you to accomplish what you are wanting.

Hope that helps.


That's certainly a giant step the right direction, thank you. Although I have no idea what a DOM class is or what "acc an element" means. When I said I was a novice I meant it, I learned how to make my first "Hello World" in HTML less than a year ago.
Was This Post Helpful? 0

#9 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1102
  • View blog
  • Posts: 6,909
  • Joined: 07-September 06

Re: Browser Recommended

Posted 17 May 2010 - 07:53 PM

The "acc" was a typo on my part, it should have read "add". DOM stands for Document Object Model and is used to access and modify the document using things like element traversal and insertion. I am currently working on creating a nice DOM class (so far it works with everything I have tried in IE 8, Chrome and Opera 10 so I think it will work on Safari and FF as well). Either way the easier route it to prepend the html to the beginning of the document body as you can control exactly what HTML is added, how it is formatted and everything else in only a few lines (instead of having to create a new element and apply everything to it using a DOM instance - which is more lines of code).

For instance, I could add this HTML to an element:
var html = '<div class="myExampleDIVclass"><span class="important">Chrome is recommended for viewing this site.</span><a href="whatever.html">Download</a><input type="button" value="X"/></div>'
document.body.innerHTML = html + document.body.innerHTML


Or I could go through and do this (Using my DOM class as it currently is - NOTE DOM class not provided):
var d = $.DOM.create("div");
var sp = $.DOM.create("span");
var link = $.DOM.create("a");
var btn = $.DOM.create("input");
var chromeRec = $.DOM.text("Chrome is recommended for viewing this site");
var dl = $.DOM.text("Download");
d.className = "myExampleDIVclass";
sp.className = "important";
a.href = "whatever.html";
btn.type = "button";
btn.value = "X";
$.DOM.append(d, sp);
$.DOM.append(sp, chromeRec);
$.DOM.append(d, link);
$.DOM.append(link, dl);
$.DOM.append(d, btn);
$.DOM.prepend(document.body, d);



Like I said, the first option is simpler and less code, but the second does allow you to read all instructions from an outside source and build elements without needing to append and modify strings, so there are good and bad things about both.

After reading some of the above posts I would like to add in that if you are doing this because the site doesn't render correctly in the other browsers then it is likely not the best idea. Most of the hassle with web development is making sure that everything you create DOES work across multiple browsers (in general there are 5 big ones, being Internet Explorer, Chrome, Opera, Safari, and Firefox). However, there are times when adding a recommended sign into the mix is worth it. For instance, if the company whose product you are recommending is paying you to do so.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1