0

I have a client which owns an index site. The index includes phone numbers for the companies listed. I want the phone number to not show up in search results and only show up when the user enters the index page and clicks a link. I don't currently use jQuery on the site, but I'm not apposed to adding it, if it makes things easier (I'm guessing it will). Any ideas on how to implement this?

Elad Lachmi
  • 10,406
  • 13
  • 71
  • 133

3 Answers3

3

Personally, I would not rely on JavaScript to show information to my customers how they can contact me. Customers with deactivated JavaScript would be unable to contact me.

A solution would be to simply exclude the page with the phone numbers through a ROBOTS.TXT file.

Or, you could render the numbers as images.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 1
    Good point, but I would still like to see some type of solution. From the latest stats of the Israeli Internet Organization 99% of users in Israel have JS enabled browsers. I'm willing to take my chances. I can't exclude these pages from search. – Elad Lachmi Apr 03 '11 at 10:41
  • 1
    I see, @Elad. Just to give you numbers: According to [this](http://www.internetworldstats.com/middle.htm#il) there are 5.2 million Internet users in Israel. So the 1% you mention are 52,000 users. Don't know if I would ignore them :-) – Uwe Keim Apr 03 '11 at 12:06
  • 1
    I wouldn't, my boss would :) Told him, doesn't care. – Elad Lachmi Apr 03 '11 at 12:08
2

If you want to use JavaScript to hide the phone number from search engines, you could break up the string and concatenate the pieces with document.write:

document.write('Phone Number: ###' + '####');

Joe Mornin
  • 8,766
  • 18
  • 57
  • 82
  • 1
    Can you please explain the logic here? – Elad Lachmi Apr 03 '11 at 22:55
  • The browser will interpret the JavaScript and display the phone number to the user as if you'd written it in plain text. However, search engines [won't interpret the JavaScript](http://stackoverflow.com/questions/2061844/does-googles-crawlers-have-javascript-what-if-i-load-a-page-through-ajax), so the phone number won't get indexed. – Joe Mornin Apr 03 '11 at 23:15
  • I see. Nice, elegant solution. Thank you! – Elad Lachmi Apr 04 '11 at 04:52
0

It's important to develop code to work with and without JS enabled, its part of the W3C Accessability guides and good practice..

This maybe a little helpful

Iamsamstimpson
  • 1,359
  • 2
  • 17
  • 32
  • It's not going to be accessible as hidden or as image. I know the importance, but my bosses want this. Not my personal first choice. I understand that you all only intend to help, but it's really not my call. – Elad Lachmi Apr 03 '11 at 10:51