0

I have an ad page, and I would like to give users the option not to see it anymore if they are not interested in my ad. I thought I would add a button that, when clicked, would send the user to their own homepage. I've tried onclick='window.home()' but it's not working in Chrome. <kbd>alt</kbd>+<kbd>home</kbd> does send Chrome to its homepage. I wonder if there is a way to use that? Or has this been prohibited in modern browsers due to security concerns?

Nathaniel Ford
  • 16,853
  • 18
  • 74
  • 88
  • possible duplicate of [Sending user to their browser's Home Page using Javascript](http://stackoverflow.com/questions/1369450/sending-user-to-their-browsers-home-page-using-javascript) – quw Aug 20 '14 at 16:40
  • Hello quantumwannabe, thanks, the question is similar yes I think, but the solutions there are based on 'window.home()', and that is not working anymore...I tried it and it doesn´t work...so that´s why I am asking for help. – Stephen Garret Aug 20 '14 at 17:14
  • I agree, it is not a duplicate since their answers are out of date. Closest you can get for Chrome then is probably `about:newtab`. – quw Aug 20 '14 at 17:22
  • Thank you, quantumwannabe, I´ll look into it too, might come in handy...kirinthos has pointed me towards learning about cookies, that should do the trick...at least I hope...it would be easy to make a popup, but what I need is for the user to see my page (the ad opens automatically) and then have the choice to go to my company´s page or set the ad to "will see it later" or "don´t want to see this", and then be directed automatically to his/her homepage. Again, I could direct him/her to a webpage of my choice, but I want to respect the user... – Stephen Garret Aug 20 '14 at 17:54

2 Answers2

1

According to the documentation at Mozilla Developer network, its not supported in Chrome. https://developer.mozilla.org/en-US/docs/Web/API/Window.home

dhyppolite
  • 26
  • 3
0

If I understand your question correctly, the functionality to redirect to the user's home page is not universally defined in all browsers. How exactly does sending a user to their home page relieve them of seeing your ad? wouldn't it be better to, say, store a cookie, and look at that value to determine whether or not to show some ad?

it also seems like this question was asked here

Community
  • 1
  • 1
kirinthos
  • 442
  • 2
  • 9
  • Thanks for your answer. Yes, in a "perfect world", what I would really like is to give the user say 3 options: "Don´t show this to me again", "Not now, show this to me again tomorrow", and "Not now, show this to me again in 3 days", but I don´t have any idea how I could achieve that. I don´t know how to work with cookies, I have just learned how to work with local storage a few days ago...// the question you pointed to is old, as dhyppolite pointed out, it doesn´t work any more, it is about "window.home"... – Stephen Garret Aug 20 '14 at 17:10
  • [w3schools](http://www.w3schools.com/js/js_cookies.asp) actually has some good info on using cookies, basically you would set a few values in the cookie. the type of option they picked (never, few days, one day), and the day you last showed them the ad. some simple js can do some date math and figure out if you should show the ad. – kirinthos Aug 20 '14 at 17:27
  • Thanks again, Kirinthos! Yes, that does seem to be the answer, I´ll try learning it...ah, just one thing though, as I KNOW I´ll run into some difficulties till I get it right, is there a way I could show you my code if it´s not working? Could you please help me with it? My boss asked me to fix it till Friday, so I´m really pressed for time on this...any help would be greatly appreciated...I don´t know if it´s allowed to give one´s email address here, but I could send you mine... – Stephen Garret Aug 20 '14 at 17:35
  • i would love to help you, but i'm pretty swamped with work myself. i'm not sure if it's a violation to share email addresses on this site, but if you want to comment on here with your question, or open a new SO question (if it hasn't already been asked) i'd be happy to help with the time i can afford – kirinthos Aug 20 '14 at 17:43
  • Ok then, I´ll keep posting my blunders here, at the very least you´ll have something to laugh at, thanks very much for your help! :) – Stephen Garret Aug 20 '14 at 17:56