Jump to content
  • Advertisement
Sign in to follow this  
gretty

Your techniques for overcoming different browser HTML display

This topic is 2629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello

I am developing a Website Updater. The front end uses normal HTML, CSS & Javascript. The backend uses Python scripts. The way it works is that certain p, b, etc HTML elements are part of the class "updatable". To update these elements I load the webpage but convert all elements of the class "updatable" to textarea's(using JQuery). Once they have made their content updates, I change them back to their original elements, grab the HTML using either ele.innerHTML() or $(ele).html() & send it to a python script to store the new content.

My Problem: I am finding that different browsers change the original HTML. How do you get around this issue? What libraries(python specific) do you use, what techniques/application designs doyou use to avoid/overcome this issue?

The problems I face are:
- IE removes the quotations around class & id attributes: "from < img class='abc'/> to < img class=abc/>"
- Firefox removes the "\" char from the < br> tags: from "< br> to < br>"
- Some websites have very specific display technicalities, so an insertion of a simple "\n"(which IE does) can affect the display of a website: "from < img class='headingpic'/>< div id="maincontent">... to < img class='headingpic'/>\n < div id="maincontent">... "
Something like the above inserts a vertical gap in IE only.

The things I have tried to overcome these issues(all unsucessful):
- Using JQuery string functions to remove all ">\n<" occurences, "< br>" etc.But this fails because I get different patterns in IE, sometimes an " \n", sometimes an "\n ".
- Using Python on the server side to perform the same string functions.
- In a python script, parsing the new HTML, extract the new text/content, insert it into the old html so the elements & format never change just the content. This is very diffcult & overkill.

Share this post


Link to post
Share on other sites
Advertisement


I am developing a Website Updater.

What is that?

The way it works is that certain p, b, etc HTML elements are part of the class "updatable". To update these elements I load the webpage but convert all elements of the class "updatable" to textarea's(using JQuery). Once they have made their content updates, I change them back to their original elements, grab the HTML using either ele.innerHTML() or $(ele).html() & send it to a python script to store the new content.[/quote]

This sounds as something very unusual. What are you trying to actually do?

Share this post


Link to post
Share on other sites

[quote name='gretty' timestamp='1317954537' post='4869952']
I am developing a Website Updater.

What is that?

The way it works is that certain p, b, etc HTML elements are part of the class "updatable". To update these elements I load the webpage but convert all elements of the class "updatable" to textarea's(using JQuery). Once they have made their content updates, I change them back to their original elements, grab the HTML using either ele.innerHTML() or $(ele).html() & send it to a python script to store the new content.[/quote]

This sounds as something very unusual. What are you trying to actually do?
[/quote]

I understand what he's doing, but he's not going to be able to do it this way. You'll probably be better off if you assign every updatable element a unique ID, then post those changes back to the server packaged up in some JSON (python has a JSON parser module included). Then you'll have to insert the data into the original HTML using string manipulation and likely regular expressions to find the right place to put the new content.

But this is not a good idea. Use some sort of template system. In the template, insert tags like ##field1## that you can easily find and replace when sending the page to the browser.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!