|
|
How to convert this to just HTML?
|
|
|
|
Mac Elite
Join Date: Jan 2001
Status:
Offline
|
|
Hi,
I'm trying to include this weekly safety tip on one of my sites, but they force formatting on me by using Javascript. See here:
http://www.nsc.org/syndy/weeklytip/safetytip.js
Anyone know of some PHP code that will take just the html and spit it out? Aka, remove the \n's and the +'s and the Javascript code?
Thanks!
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status:
Offline
|
|
try strip_tags (php function).
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
I think he's trying to keep the HTML and get rid of the other stuff.
I'd recommend just doing some str_replace functions for the +s and
\n, though I can't imagine any reason for dropping the newlines, they aren't going to affect your html.
Code:
<?php
$text = "document.writeln('<table width=\"150\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"' +
'bordercolor=\"ffffff\" bgcolor=\"ffffff\"><tr><td bgcolor=\"ffffff\" align=\"center\">' +
'<a href=\"http://www.nsc.org/library/facts.htm\" target=\"_blank\"><img src=\"http://www.nsc.org/syndy/weeklytip/wst_hdr.jpg\"' + 'alt=\"Weekly Safety Tip\" border=\"0\"></a></td></tr><tr bgcolor=\"ffffff\">' +
'<td style=\"font: normal 10px Verdana, Arial, Helvetica, sans-serif; padding:5px,5px,0px,5px; text-align:left;\">' +
'<p><b>Winter, Your Car, and You</b><br />Do not leave your car unless you know exactly where you are, how far it is to possible help, and are certain you will improve your situation.</p>' +
'</td></tr>' +
'<tr bgcolor=\"ffffff\">' +
'<td bgcolor=\"ffffff\" align=\"center\">' +
'<img src=\"http://www.nsc.org/syndy/weeklytip/wst_ftr.jpg\"' + 'alt=\"Weekly Safety Tip\" border=\"0\">' +
'</td></tr></table>');";
$text = str_replace("+","", $text);
$text = str_replace("'","",$text);
$text = str_replace("document.writeln(","",$text);
$text = str_replace(");","",$text);
print $text
?>
So it's not the most elegant solution, but it works.
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|