Forum Moderators: open

Message Too Old, No Replies

Javascript code as <href> value - is it possible

         

alexod

11:01 pm on Jul 20, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hello

I have a such code

 <a href="tel:1111"></a>


Site owner asked my to include Javascript code as a link. Something like this

 <a href="tel:<script type="text/JavaScript" src="https://***/js/keyword_replacement.js"></script>"></a>


it's a 2 block javascript code (1st block i must include in head and the second block will generate phone number - each time new nubmer).

So my question is - is it possible to include such a code into href="tel:"

Like this


<a href="tel:<script type=\"text/JavaScript\" src=\"https://**/js/keyword_replacement.js\"></script>">1</a>

or

<a href='tel:<script type="text/JavaScript" src="https://**/js/keyword_replacement.js"></script>'>1</a>
or
<a href="tel:<script type="text/JavaScript" src="https://**/js/keyword_replacement.js"></script>">1</a>


No of this code didn't work properly

Any advice will be appreciated.

-
David

rainborick

3:12 am on Jul 21, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can't embed one HTML tag within another. You need to create the original text in JavaScript as well as call the external script. Your code needs to be something like:

<script type="text/javascript">
document.write('<a href="tel:');
</script>
<script type="text/JavaScript" src="https://***/js/keyword_replacement.js"></script>
<script type="text/javascript">
document.write('">1</a>');
</script>

lucy24

4:54 am on Jul 21, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



document.write ? Really? (Sure, I've used it, but in most circumstances I'd be scared to death of obliterating the whole page by mistake.)

topr8

6:21 am on Jul 21, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



or you could give the a href tag an id, you could then run a script that writes the telephone number (on page load)

... the main question is why do you want to do this?
if the client thinks the telphone number won't be scraped by writing it in js, they may be mistaken, especually as once the phone number is out there, other sites will use it in their directories and those directories get scraped anyway.

alexod

11:22 pm on Jul 21, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



thank you guys

Topr8
No, the problem is other. My client is using dialogtech_com phone pool, that's why we put this js code on webpage. Each time page loads, it generates new phone number (so phone numbers are dinamic). That's the reason why i can not use static numbers.

topr8

6:32 am on Jul 22, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ah! fair enough.