SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question 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??

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    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:

    Code JavaScript:
    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:

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

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

    Code HTML4Strict:
    <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
    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx friend!!now i think i know what i have to do.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •