Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to convert this to just HTML?

How to convert this to just HTML?
Thread Tools
timmerk
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Dec 27, 2006, 08:57 PM
 
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!
     
mania
Mac Enthusiast
Join Date: Aug 2001
Location: Durango CO
Status: Offline
Reply With Quote
Dec 28, 2006, 12:18 AM
 
try strip_tags (php function).
The Bitcastle
graphic design, web development, hosting
     
SirCastor
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status: Offline
Reply With Quote
Dec 28, 2006, 11:57 AM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:13 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,