Parsing web pages using javascript

hello folks,
basically i am a c++ developer and dont know much about javascript. i am developing a application for mobile. this application loads a certain forums website.the mobile platform itself support javascript and html in applications so there is no problem in rendering webpages in application.
The problem is, site is not optimize for mobile screen and i have to do too much horizontal scrolling.this ruins the whole web application.
so i thought a way to do this:-
i want to load whole web page first into a variable and by parsing the content of variable, i want to find the data required (like content of a user’s post) and then display it by putting it in a new html file whose divs and span are optimized for mobile screen.but i dont know how to load content of a whole webpage into a varible in javascript and how to parse that value (:(:.

Can any one help me on this issue?? Or suggest me another way to load a webpage in a application??

Would it be possible to inject a separate CSS stylesheet in to the HTML from your app? If you can do that, then you would be able to restyle a bunch of things using CSS.

In JavaScript this can be accomplished like so:


var newCSS=document.createElement("link");
newCSS.setAttribute("rel", "stylesheet");
newCSS.setAttribute("type", "text/css");
newCSS.setAttribute("href", "/path/to/mobile/optimized/styles.css");
document.getElementsByTagName("head")[0].appendChild(newCSS);

Though if you’re a c++ programmer it might be easier for you to do this in your native language by injecting something like:

<link rel="stylesheet" type="text/css" href="/path/to/mobile/optimized/styles.css">

Alternatively, the entire website might benefit from a mobile optimized stylesheet:

<link rel="stylesheet" type="text/css" href="/path/to/mobile/optimized/styles.css" media="handheld">

(Note the media attribute)

Of course for the latter option you would need to be able to place that stylesheet in to the <head> section of the website and make sure (most of?) the other stylesheets have an appropriate media attribute set. I realise that you probably don’t have access, but thought I’d include it for completeness sakes :wink:

thanx friend!!now i think i know what i have to do.