Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    405
    Thanks
    17
    Thanked 2 Times in 2 Posts

    javascript to search one page for a file path to put on another.

    I'm working on a site built through Squarespace, and I've run into some limitations. They've told me it's possible to build a Javascript to pull specific images from one page's journal entries and place them (with links to the entry) on other pages.

    Can somebody send me in the right direction on how I would do this? Basically I want to find a most recent posting tagged with a specific category, find the file file path of it's related image, and make that appear on the page that my javascript is on.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,195
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    This only possible if both pages are coming from the same domain. That is, if both pages are served up by the same web server (or at least server group).

    If it is, then it's not hard. But...

    -- Are both pages visible at the same time? That is, is one a popup from the other?
    -- If so, which page opened the other one?

    If only one page is to be visible, then the easiest way to do this is to load the other page into an invisible <iframe> on the visible page and then search for the desired content within the HTML of the invisible <iframe>.

    In any case, we need to know *HOW* the "most recent posting [is] tagged with a specific category". That is, what does the HTML that makes this obvious look like?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder
    Join Date
    Aug 2010
    Posts
    405
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Both pages are on the same domain. I was thinking I could have the first page load quickly, or hidden, then pull the info and pass the info to a second page. But <iframe> might make more sense - if it's possible with the cms program my client is using (Squarespace).

    Basically I'm building a page that's pulling rss feeds from individual pages on the same domain (built that way due to a limitation of the cms software the client is using) I want to detect the most recent post for each category, and pull the thumbnail picture to appear here, as the layout suggests: http://www.frontdoorsnews.com/-4/

    An example of the pages I want to pull the pic url from is here: http://frontdoorsnews.squarespace.com/from_the_heart/

    On this page, a specific div tag (div id="item12616108") matches the category. I could rebuild it to have divs for all the categories.

    Inside that div is another div class called "journal-entry-float-day". I can change that to include hour and minute, so it can be used to find the most recent post.

    Buried a couple div's down is an image. There will only be one per post, so maybe this is my method? Let me know if this theory works, and give some suggestions on scripting this? I'm a little bit new to javascript building.

    Hope I'm on the right path!
    Last edited by turpentyne; 08-26-2011 at 06:51 PM.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,195
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Seems you have found the right idea, judging by your other thread that I have replied to. If not, ask again.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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