0

This method escapes all &, <, and > symbols in the string, making it safe to display the string on a web page without fear that it will be treated as HTML.

[code]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Usefull Prototype</title>
</head>
<body>
<script type="text/javascript">
<!-- Begin Hiding
String.prototype.show_tags = function()
{ return this.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').fontcolor('green').bold(); }
String.prototype.normal_text = function() 
{ return this.fontcolor('blue'); }
<!-- U S A G E -->
var text = 'Some examples of common tags'.normal_text();
document.write('<html>'.show_tags() + '<br />');
document.write('<head>'.show_tags() + '<br />');
document.write('<title>'.show_tags() + text + '</title>'.show_tags() + '<br />');
document.write('</head>'.show_tags() + '<br />');
document.write('<body>'.show_tags() + '<br />');
document.write('</body>'.show_tags() + '<br>');
document.write('</html>'.show_tags());
// Done Hiding -->
</script>
</body>
</html>[/code]
2
Contributors
1
Reply
9
Views
9 Years
Discussion Span
Last Post by westworld
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.