Convert Text to JavaScript
One reason for using JavaScript to publish content on web pages is to evade the attention of certain types of robots. (The text to JavaScript conversion software that comes with this article can be used to create the JavaScript.)
Form spamming robots, for example, won't find the word "form" or "input" in the web page source code, or other words directly associated with forms. When no form is found, they can meander to another URL on their list.
Primitive bots sent out to fetch the content of a web page are likely to omit JavaScript.
Another reason for using JavaScript to publish content is to make it available only if the browser has JavaScript turned on. Perhaps you wish to publish links to games or other content that can work only with JavaScript. Or you wish to publish content only when the page is loaded in a certain browser.
Search engine spiders probably won't skip over JavaScript, like they used to a few years ago, especially the more popular ones. Thus, except for primitive search spiders or spiders designed to specifically omit JavaScript, this is unlikely to be an effective search blocker. If certain words or phrases need to stay out of search results it may be better to employ a different technique, such as presenting the text as an image.
To convert text to JavaScript, you can:
-
Use the source code of the converter (see further below) and upload it to your website to use.
-
Use the demonstration converter implementation at this website.
The content published with JavaScript may be a word, a phrase, a paragraph, or an entire article.
Here is the complete PHP web page to convert text to JavaScript. No customization is required.
<!DOCTYPE html> <html lang="en"> <head> <title>Text to JavaScript Converter</title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css"> body { font-family:sans-serif; margin:50px 0 50px 100px; } textarea { width:100%; height:12em; box-sizing:border-box; } input { width:100%; box-sizing:border-box; } a { text-decoration:none; } p { line-height:130%; } </style> </head> </body> <div style="max-width:500px; margin:.25in auto;"> <a href="http://www.willmaster.com/"> <img src="http://www.willmaster.com/images/wmlogo_icon.gif" style="width:50px; height:50px; border:none;" alt="Willmaster logo"> </a> <h3>Text to JavaScript Converter</h3> <?php if( empty($_POST['text']) ) { $_POST['text'] = ''; } if( isset($_POST['submitter']) ) { $_POST['text'] = stripslashes($_POST['text']); $_POST['text'] = trim($_POST['text'],"\r\n"); echo <<<TOPPARTRESPONSE <p> The JavaScript converted from text is in this box. Paste it into the source code where it is to be published. </p> <textarea name="_blank" onclick="select()" wrap="off" style="white-space:pre;"> <script type="text/javascript">\n TOPPARTRESPONSE; foreach( explode("\n",str_replace("\r",'',$_POST['text'])) as $line ) { $js = $line; $js = preg_replace('/<\?php[^>]+?\$_SERVER\[\'PHP_SELF\'\][^>]+?\?'.'>/','PHP_SELF-FLES_PHP',$js); $js = str_replace("\\","\\\\",$js); $js = str_replace("'","\\'",$js); $js = str_replace("<!--","<'+'!--",$js); $js = str_replace("-->","--'+'>",$js); $js = preg_replace('/(spa)(m)/i','$1\'+\'$2',$js); $js = preg_replace('/(for)(m)/i','$1\'+\'$2',$js); $js = preg_replace('/(typ)(e)/i','$1\'+\'$2',$js); $js = preg_replace('/(inp)(ut)/i','$1\'+\'$2',$js); $js = preg_replace('/(emb)(ed)/i','$1\'+\'$2',$js); $js = preg_replace('/(sel)(ect)/i','$1\'+\'$2',$js); $js = preg_replace('/(act)(ion)/i','$1\'+\'$2',$js); $js = preg_replace('/(scr)(ipt)/i','$1\'+\'$2',$js); $js = preg_replace('/(win)(dow)/i','$1\'+\'$2',$js); $js = preg_replace('/(doc)(ument)/i','$1\'+\'$2',$js); $js = preg_replace('/(tex)(tarea)/i','$1\'+\'$2',$js); $js = preg_replace('/PHP_SELF-FLES_PHP/',"'+document.URL+'",$js); echo "document.writeln('$js');\n"; } echo <<<BOTTOMPARTRESPONSE </script> </textarea> BOTTOMPARTRESPONSE; } ?> <p style="margin-top:2em;"> In this box, type or paste the text to convert: </p> <form method="post" action="<?php echo($_SERVER['PHP_SELF']); ?>"> <textarea name="text" wrap="off" style="white-space:pre;"><?php echo(htmlspecialchars($_POST['text'])); ?></textarea> <p> <input type="submit" name="submitter" value="Convert to JavaScript" /> </p> </form> </div> </body> </html>
Save the above source code as any web page file name ending with .php
and upload it to your server. To use the software, type its URL into your browser.
Perhaps some of the reasons to publish content with JavaScript given in this article are reasons that affect your website.
If yes, convert the relevant text into JavaScript with the demonstration installation or install the JavaScript converter on your server.
(This content first appeared in Possibilities newsletter.)
Will Bontrager