dcsimg
www.webdeveloper.com
Results 1 to 9 of 9

Thread: www.mysite.com/colors/nnnn - how to get the nnnn customized part ?

  1. #1
    Join Date
    Nov 2017
    Posts
    4

    www.mysite.com/colors/nnnn - how to get the nnnn customized part ?

    Hello webdeveloper.com community !

    I suppose my headache is related with JavaScript rather than html.

    So, I have a Wix website and a page www.mysite.com/colors with 4 buttons for picking 4 colors.
    I saw elsewhere the use of generated URL, easy to share in communities, for going directly to a wanted choice, like www.mysite.com/colors/1100 for showing the first two colors, or
    www.mysite.com/colors/1010 for showing 1st and 3rd colors already selected.

    My question, as the guy behind the www.mysite.com/colors page, is how to read/retrieve the /nnnn parameter when my page is loading from such a link ?
    Right now, the link www.mysite.com/colors/1010 will correctly (and solely) open the www.mysite.com/colors page (no errors) but I donít know what mechanist/function is used on other sites to recover that /1010 (I would know how to interpret it).

    My site is hosted by Wix and the JavaScript is embedded into a capsule. I tried window.location.pathname but it shows only a rather undecryptable path of the Wix page. I donít know if the embedded JavaScript can intervene in time when that ďcleanĒ URL is loading, even if I use onload event. Also, I donít know if it is a matter of JavaScript or other technology, with those www.mysite.com/colors/1010 style shortcut links.

    Any help will be greatly appreciated !
    Best regards

  2. #2
    Join Date
    Dec 2005
    Location
    TX
    Posts
    7,916
    I believe what you are looking for is the querystring.
    See: https://search.yahoo.com/search?fr=m...pt+querystring

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,434
    This is a good resource for people starting coding in javascript, https://www.w3schools.com/ and it gives you a basic run down of what each property and method of these objects.

    The location object (often written as window.location) in this example gets the pathname, location.pathname https://www.w3schools.com/jsref/prop_loc_pathname.asp from the root and the query part of the string can be found using location.search https://www.w3schools.com/jsref/prop_loc_search.asp
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  4. #4
    Join Date
    Nov 2017
    Posts
    4
    Hello JMRKER and \\.\

    Iím afraid I was not clear enough.
    /nnnn is not a true querystring but a simple custom matrix of added 0/1s after the page address, simple to write down by anyone, which triggers some integrated script/element. And I am searching for that function which detect the added /nnnn when my page is loading.

    I already tried location.pathname when loading my www.mysite.com/colors/ page and it gives :
    /html/1eb574_7e821206b37c32ab7e510c9383068a31.html
    !!!
    I suppose itís the path to the imported-by-Wix page, however I cannot even recover the official basic Url !

    I need to detect that entered Url of www.mysite.com/colors/1010 and especially that /1010 part which will show www.mysite.com/colors/ page with the triggered 1st and 3rd buttons.

    Once I recover the matrix I know how to trigger what itís needed but I donít know what technology is behind the web pages which can function like this.

  5. #5
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,434
    So where do you want this URL got? At the server or on the clients machine? If you want to get the query string at the server, you need to look a PHP's set of variables for that information.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  6. #6
    Join Date
    Jul 2003
    Location
    The City of Roses
    Posts
    2,535
    Quote Originally Posted by titiwi View Post
    I already tried location.pathname when loading my www.mysite.com/colors/ page and it gives :
    /html/1eb574_7e821206b37c32ab7e510c9383068a31.html
    !!!
    My best guess to explain this discrepancy is that your JavaScript is inside an iframe. Try
    Code:
    window.top.location.pathname
    and see if that makes a difference. Otherwise, I think we'll need to see this page you're talking about to figure out what's going on.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  7. #7
    Join Date
    Nov 2017
    Posts
    4
    My site being hosted by Wix, with JavaScript allowed in "capsules" in already "encapsulated" pages, yes, I suppose it's an iframe.

    I found an example of site using what I'm searching for :

    www.shipcom rade.com/captcalc
    (remove the space between shipcom and rade)

    Just pick anything on the first line then next lines. Bellow the table there is a Url Builder which generates the aforementioned ďmatrixĒ custom link. Now paste it again in a new window and see the table automatically adjusting.

    I would like to know what technology is behind, for searching the developerís universe with the good keywords and find more exemples.

  8. #8
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,434
    The point is you are being asked for information about your site, not some one elses that doing something you like or want...

    If you want help, please provide the information you have been requested to provide so people can assist you. Currently you have people guessing as to what the problem is or what your asking for.

    Please remember to use Forum BB Code tags (examples in my signature) to wrap around your code blocks.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  9. #9
    Join Date
    Nov 2017
    Posts
    4
    I admit I am a bit lost in space, not knowing what exact technical term to ask, instead of the lyric description I wrote in the first post which correspond to that recent example of tier-party site where it is working.

    I donít have such a page yet, able to recognize a matrix added in the url, I want to develop one ! Thatís the reason of my entire quest here.

    I was supposing/hoping it could be JavaScript-related but following your feedback I am less and less sure.

    Btw I tried that, and the html file on my PC is giving the correct path, however once uploaded to my Wix space there is no more message alert at all.
    Quote Originally Posted by Jeff Mott View Post
    My best guess to explain this discrepancy is that your JavaScript is inside an iframe. Try
    Code:
    window.top.location.pathname
    and see if that makes a difference.

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