1

Basically, I'm trying to get ASP.NET to grab a variable out of the URL and use it to start a javascript function.

The user is viewing an online catalog (built with turn.js, a plugin for jquery), and when a page is clicked, it goes to a webpage with all the products from that catalog page on it. There's a link there back to catalog, but when you go back the catalog starts back at page 1. If I have the link include the page number in the URL (i.e. website.com/catalog.aspx?page=4) when you go back, I believe I can grab that out of the URL and use it to have the catalog turn to that page when it loads.

I usually stick to PHP, so I'm a bit lost here. I just need to write a little code snippet that will grab the page number and fire a javascript function using the number. Is this possible?

EDIT: Code:

Here's what I've got in javascript:

function changePage (pagenumber) {
    $("#flipbook").turn("page", pagenumber);
}

The page itself is run by NetworkSolutions, so I can't give you any of the actual code from the webpage. What I came up with so far from looking around the web is this (I hope I'm not doing this completely wrong):

<script runat="server">
    void Page_Load (object sender, EventArgs e) {
        var pagenumber = Response.QueryString['page'];
    }
</script>

I'm not sure if I'm getting the variable correctly, or even what to do with it after that to fire the javascript function. Thanks for any help given!

1
  • Please show your code. Commented Dec 17, 2013 at 0:46

3 Answers 3

2

If I understand well your question, you want to grab the page number in the querystring using javascript, if that's correct, would this help?

How can I get query string values in JavaScript?

Sign up to request clarification or add additional context in comments.

1 Comment

Ah, I didn't think it was possible to use javascript to get query string variables. I'll give it a try.
2

Im using this plugin

Example:

To get the document params:

var value = $(document).getUrlParam("paramName");

To get the params of a html-attribut (uses src attribute)

var value = $('#imgLink').getUrlParam("paramName");

it works for me. Thanks the author.

Comments

2

you can use server tags as below

function changePage (pagenumber) {
    $("#flipbook").turn("page", <%= Request.QueryString['page'] %>);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.