Results 1 to 7 of 7

Thread: Can i know if an url is present inside the browser history?

  1. #1
    Join Date
    Jan 2013

    Question Can i know if an url is present inside the browser history?

    I know that HTML5 have introduced the history API, and infact i'm using it for push states inside urls and memorize it into the history.

    I need that for this purpose: i've created a page for personal purpose that performs a scan to a webstore for keep trace of prices, and print results inside mine.
    I need to know if from my last visit some prices are changed, and for do this i memorize my last visioned product/price couples as url inside the history

    something like www.domain.com/index.php?producName=somename&price=someprice

    Nextime i load the page, i need to know if a certain url (www.domain.com/index.php?producName=somename&price=someprice) is present or not inside history, if yes, assign the "visited" value withint the class parameter of the element, if not, i will do other things.

    Anyway, in few words, i need to read in some way the browser history, or i can't proceed with my idea.

    PS: yes, i know that i could memorize this type inormation inside a file in server side scripting, instead of use history, but for the moment i've designed the project for work essentially client side.
    Last edited by American horizo; 04-05-2014 at 01:30 PM.

  2. #2
    Join Date
    Mar 2005
    Behind you...
    The short answer: no.

    The HTML5 History API is more or less designed to allow users to push urls into the history so while dynamically loading pages, a user can still have the standard expectation of using their browsers forward/back buttons to navigate these dynamic pages. It is not designed to grant access to the actual browser's history and the history object is even further limited by the pages navigated within a current session of that specific tab. For example, If I go to google.com, search for 'hats' then open a result, the history object on this hats page only holds data for google.com and my google search results page. But even then the actual urls are never exposed, only the number of pages in that history session (3) and the ability to navigate those pages.

    A user's browsing history will likely never be openly exposed by javascript, HTML or any other language as it's a privacy/security issue. On a related note you actually are given very limited control over CSS when setting the a:visited properties for a similar reason. Since the :visited pseudo selector is directly linked to a user's browsing history the CSS properties allowed is drastically reduced to prevent any potential exposure of previously visited pages.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  3. #3
    Join Date
    Feb 2014
    The history API does allow you to access a user's browser history but it's a lot more limited than what you're after. There used to be a security loophole based on CSS whereby a previously visited website link would change colour, however, it is a few years old and has since been fixed (unless I'm completely mistaken). The only way I can see you doing what you're after and from a client-side approach is if you created your own browser that had next to no history security and the history object stored all of the pages visited no matter the amount.

    I wouldn't say you cant proceed with your idea, you just have to re-visit the drawing board, unless you do want to take the route of creating your own browser.

  4. #4
    Join Date
    Jan 2013
    bad story.
    I also thought to use cookies... But memorizing a lot of cookie, after i loaded the page once, next time it retrieve me a Bad request error, i assume due to the large number of cookie generated

    So, can maybe i use one single cookie to store an abnorm string or there are limits of size?

    As a last resort, i need to re-design the entire structure of the script, using PHP instead of jquery for access html elemens... For this reason, there exists a library that allow to read elemnt in a simplest way?
    For exemple, if inside my PHP code i've a variable in which is stored an html code, can i extract from it single elements with specified classes (such jquery does) farther using regexp ?
    Last edited by American horizo; 04-05-2014 at 06:44 PM.

  5. #5
    Join Date
    Feb 2014
    A single cookie can only store up to 4 KB, however, if the data size becomes an issue, then you shouldn't be using cookies for that data.

    PHP is server-side, meaning it will have access to data sent between the webpage and the server. Generally, JavaScript or jQuery are used to read the information from the HTML elements and send it to the server. There are different ways to send it to the server depending on how you want the website to behave.

    For your second question, PHP can extract information contained in HTML class attributes. There are built-in functions to read by ID and tagname (i.e. <td>) but not by class. If the same class is always used in the same type of HTML element, then you can read all of those tag names and use string manipulation to get the classes.

  6. #6
    Join Date
    Mar 2005
    Behind you...
    Don't forget about localStorage in HTML5. The typical standard limit is 5MB, which I would have to assume should be enough given the type of data you are storing. And expanding on that even further, you could even utilize the Indexed DB API of HTML5 if you care to have a much more structured way or storing your data all while doing it locally.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  7. #7
    Join Date
    Jan 2013
    I think that local storage is perfect for my purpose, thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.09368 seconds
  • Memory Usage 2,907KB
  • Queries Executed 15 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates