Welcome to TalkGraphics.com
Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1

    Default IF condition for javascript:history.back(-1)

    Here is a short explanation, why I´m looking for such a function:

    I do have
    P1) a PRODUCT FAMILY PAGE page which describes the "main features" of the whole product family, ie.
    P1. a) reliability
    P1. b) expandability
    P1. c) ...
    plus several PRODUCT PAGES like
    P2) entry level models with detail specifications and pictures
    P3) mid range models with detail specifications and pictures
    P4) high end models with detail specifications and pictures

    To avoid extensive page size of every product page by repeating the "main features" I can use on every product page a back link to the product family page (> 1) either to a specific headline or anchor.

    I can guarantee a continous reading for the visitor with a back/continue button with "javascript:history.back(-1)", which bring the visitor back exactly to the point of the product page, where he has clicked the link.

    So far so good.

    My problem is, that it makes no sense to have this special "back/continue button" all the time visible on the PRODUCT FAMILY PAGE, as it would only work correctly if "history.back(-1) = P1, P2, P3

    My idea was to but the special "back/continue button" on a separate layer, who becomes only visible, if the IF Condition is correct otherwise it is hidden for all visitors starting to read the PRODUCT FAMILY PAGE 1st from top to the end.

    I would be very happy, if there is a way to do it.

    THX in advance.

    Best regards
    Erwin
    Greatings from Vienna/Austria

  2. #2
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,749

    Default Re: IF condition for javascript:history.back(-1)

    Erwin, would it work for you if you put each Product as a pop-up layer in the Product Family page?

    If you have a large number of Product pages, the better way might to include them as content of a single IFRAME on the Product family page.
    Each would have a Link to Product (page) but the Link target would be the name of the IFRAME Placeholder.

    Here is a mock-up: IFRAME - Product Family.xar

    I would not rely on the browser's handling of a javascript call alone.
    The code you want is either window.history.back() or window.history.go(-1), history.back() has no parameter.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  3. #3

    Default Re: IF condition for javascript:history.back(-1)

    Hi Acorn,
    thank you for your quick reply and the mock-up as well.

    I found the information of the back-button here in an old Thread named "Create 'BACK' button to emulate browser back button"

    Conerning your mock-up:
    Basically it´s an interesting approach, but I have some concerns to do it that way
    1) some of the product pages include more than 20 model numbers (PN´s) now as H2, which should be found by a search engine, as customers often search about a specific pn to get an alternate source or offer, which means I´am afraid to lose this benefit
    2) it is hard enough to find a layout, which works with 960px as well as 480px mobile friendly, which has become most important in the meantime and is the main reason for a complete redesign of the site. Out of my experience, I try to keep the design straight and simple and use layers and popups very sparingly. To share a maximum of content between 960px and 480px is the main goal, otherwise it ends up in creating each page twice, which becomes a never ending story, as the website, I currentyl work on is about 40 pages large.

    Beside your concerns about the different behaviour of browsers using one of the forms of javascript for a back button (see "Create 'BACK' button to emulate browser back button"), is there a way to have some lines of code in the header to make a layer visible if the result of the "IF" is that last page was P2, P3 or P4. The worst it might happen, is that the layer, where I hide the back-button does not become visible, with some browsers. In this case the visitor still has the possibility to get back to the specific product page, through my top navigation.

    Thank you in advance for your help.

    Best regards
    Erwin

  4. #4
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,749

    Default Re: IF condition for javascript:history.back(-1)

    Erwin, relying on back() might cause problems.
    Initially, I thought window.history.length would be useful to check if the back() button needed to be visible; its value never decreases!

    You might be able to use document.referrer.
    If a viewer opens a browser tab from a typed in link, the referrer is an empty string so the Back Button would be hidden.
    If they have followed a link then the referrer would be away from your site and the Back button would be hidden.

    I think this covers it: JS - Back Button.xar - DO NOT USE. There is an updated version in Post#6.

    Acorn
    Last edited by Acorn; 26 July 2022 at 04:24 PM.
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  5. #5
    Join Date
    Aug 2000
    Location
    Harwich, Essex, England
    Posts
    21,895

    Default Re: IF condition for javascript:history.back(-1)

    How about making your back link a home button shared on every page linked to index page and just draw a rectangle above it to hide it on the index page or am I missing something?
    Attached Files Attached Files
    Egg

    Intel i7 - 4790K Quad Core + 16 GB Ram + NVIDIA Geforce GTX 1660 Graphics Card + MSI Optix Mag321 Curv monitor
    + Samsung 970 EVO Plus 500GB SSD + 232 GB SSD + 250 GB SSD portable drive + ISP = BT + Web Hosting = TSO Host

  6. #6
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,749

    Info Re: IF condition for javascript:history.back(-1)

    Quote Originally Posted by Egg Bramhill View Post
    How about making your back link a home button shared on every page linked to index page and just draw a rectangle above it to hide it on the index page or am I missing something?
    Egg, I think Erwin is asking to step back through all prior pages until the initial page, which could be any of the site, is reached.

    I have just discovered the uploaded design file does not have each Back Button with Name of 'back' properly added.
    I did have a XPro+ crash when building the design and I thought I had recovered everything.

    Corrected design file: JS - Back Button.xar

    To prove it is working:

    • Preview Website
      • Back Button is hidden on index page.

    • Navigate to any pages with Next/Previous or page pick.
      • Keep pressing the Back Button until it vanishes.
      • Check this is the index page.

    • In the design, move to a page other than index.
    • Preview Web Page
      • Back Button is hidden on opened page.

    • Navigate to any pages with Next/Previous or page pick.
      • Keep pressing the Back Button until it vanishes.
      • Check this is the opened page.
      • Also check that any visit to the index page shows the Back Button.

    • Without closing your XDA.
      • Open a new browser Tab.
      • Copy in any of the sites page addresses.
      • Check this page does not show the Back Button.

    • Navigate to any pages with Next/Previous or page pick.
      • Keep pressing the Back Button until it vanishes.
      • Check this is the page with the copied address.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  7. #7

    Default Re: IF condition for javascript:history.back(-1)

    Hi Acorn,
    your JS - Back Button.xar is already very close to the solution.
    Unfortunately I´am not familar with Java script, but I understand the logic. It would be the solution, if lcl value gets the value >=1 if document.referrer ="product1" or "product2". It would not be a problem to do it less elegant, which means hard coding the complete page URL, like "https://www.mysite/vendor1/product1.htm".

    From the response from Egg Bramhill (also thank you) I learned that my initial description has space for missunderstanding.
    I prepared a small .xar with 3 pages, which should make clear everything.
    Unfortunately I see no way here to upload this file. Can you please tell me how I can send you my sample .xar.

    Kind regards
    Erwin

  8. #8
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,749

    Default Re: IF condition for javascript:history.back(-1)

    Erwin, you need to Post a reply and click on the Go Advanced button; there is an attachment icon.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  9. #9

    Default Re: IF condition for javascript:history.back(-1)

    Found it, hopefully it works.
    Attached Files Attached Files

  10. #10
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,749

    Default Re: IF condition for javascript:history.back(-1)

    Erwin, it works.

    I understand now that you are in the Product page and you want to read more about one or more of its Features without losing the ability to go back to the same Product and possibly view another Feature.

    For exaggeration, say you have a total of 100 Features across the complete Family and some Products have 10 to 20 from these as different subsets.

    I suggest the correct approach is to have the 100 Features as 100 pages - feature001 through to feature100.

    Each has a Back Button.

    The index page has a summary of all 100 Features as Links to each one.
    This could be a 10 x 10 grid of images or labels so would be quite small.
    The Product pages have similar images or text Links for their subset of Features.

    So you click forward into a Feature and you Back link from a Feature to the calling page.

    If you think you need to see all the Features together then you create the Features as a Scrolling website.
    This is published into the same folder as your main site but the links would require more work.
    You would add your bookmarks to the top of each page or use the Heading links or normal bookmarks to images.
    Each page has a Sticky Back Button.

    The viewer clicks a Feature Link in the main site and is taken to the bookmark in the features website.
    They can read top to bottom or just that page. Regardless of where they are, a click on the Back Button returns them to exactly where they clicked from.

    There is no need to hide the Back Button at any point.
    If someone has bookmarked a features page then you might need a Products Family (index) Link as well.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

 

 

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
  •