Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > HTML
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

HTML HTML problems, maybe you are trying to code for MySpace. Get all the HTML coding help here for your website.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 2:02 PM   #1
Alex Paransky
 
Alex Paransky's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How can I render user entered HTML without messing up my own page...

I have a case where user can enter some HTML code which is then stored
in the database. When I render the page with user's HTML any mistakes
made by the user might effect the layout of my page. For example, if
the user started a <table> tag, but did not finish it with a </table>
tag. This definitely breaks my own layout.

What I want to do, is somehow render's user's HTML (not in a popup)
without effecting my own html. I want to "SCOPE" user's html to a
particular area on the page.

Is there a way to do this with Java or JavaScript?

Thanks.
-AP_
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 2:03 PM   #2
Chris Leonard
 
Chris Leonard's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How can I render user entered HTML without messing up my own page...

Just a quick thought ....

When your user submits the HTML why not display it in a popup window and ask
them if they are sure this is correct ? If so then squirel it away in your
DB and display as intended next time.

Not sure how to do this in JS but could you search for open tags ( <?? ) and
then once found get the closing ones - messy but it would catch any
problems.

HTH

Chris


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 2:04 PM   #3
Chris Morris
 
Chris Morris's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How can I render user entered HTML without messing up my own page...

Alex Paransky <apara@standardset.com> writes:
> I have a case where user can enter some HTML code which is then stored
> in the database. When I render the page with user's HTML any mistakes
> made by the user might effect the layout of my page. For example, if
> the user started a <table> tag, but did not finish it with a </table>
> tag. This definitely breaks my own layout.
>
> What I want to do, is somehow render's user's HTML (not in a popup)
> without effecting my own html. I want to "SCOPE" user's html to a
> particular area on the page.
>
> Is there a way to do this with Java or JavaScript?


You could use IFRAME or OBJECT to keep the HTML in one place, though
there's accessibility and usability problems with that, and it may not
look much like you want either.

Perhaps a better solution would be to pass the HTML code through HTML
Tidy server-side, and then insert that into the database. Valid code
will be fine, invalid code will be fixed, though perhaps not in the
way that was intended. The suggestion made elsewhere of displaying a
preview is probably a good idea - preview post-tidy so they can fix
errors caused by tidy making the wrong guess about where to close the
tags.

--
Chris
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 2:05 PM   #4
David Dorward
 
David Dorward's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How can I render user entered HTML without messing up my own page...

Alex Paransky wrote:

> I have a case where user can enter some HTML code which is then stored
> in the database. When I render the page with user's HTML any mistakes
> made by the user might effect the layout of my page. For example, if
> the user started a <table> tag, but did not finish it with a </table>
> tag. This definitely breaks my own layout.


This can be broken down in to two issues, and should be handled on the
server by whatever process is putting the HTML in the database.

(1) Ensuring that user-entered HTML is valid and well formed

This is probably best done by running submitted data through a validator and
if any problems are found displaying an error message to them and asking
for it to be edited.

(2) Ensuring that the user can't muck anything up

This is usually best done with a whitelist of tags and attributes. Any HTML
used that isn't in the list gets either silently striped to returned to the
user with an error.

The whitelist would probably include tags such as <p>, but not <script> and
attributes such as lang, but not style.

An other option is to ban HTML entirely and use something like textile:
http://textism.com/tools/textile/

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 2:06 PM   #5
Jerry Muelver
 
Jerry Muelver's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How can I render user entered HTML without messing up my own page...

David Dorward <dorward@yahoo.com> wrote in message news:<1057239408.538553@news>...

> An other option is to ban HTML entirely and use something like textile:
> http://textism.com/tools/textile/



Or any of a number of wiki syntax offerings, like the one described at
http://allmyfaqs.com/faq.pl?Intro_and_Tour or
http://hytext.com/ww/cgi-bin/ww.pl?Quick_Start

---- jerry (WikiWriter lives at http://hytext.com/ww/ )
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , , , , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
page with no .html olwen HTML 6 07-01-2007 1:57 PM
xbox 360 messing about Teranews Console Subjects 2 06-11-2007 10:31 AM
User pages - Can HTML Be Used $atom New User Help 2 04-18-2007 11:19 AM
Query and List, PhP Main Page Auto Listing of User Actio MakeS PHP 1 08-30-2006 4:27 PM
User page JeJe Community Chat 0 07-05-2006 9:06 PM


Featured Websites




All times are GMT +1. The time now is 5:58 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98