facebox opened page get querystring

Im in a page mainpage.aspx" in which i have this code: <a rel="facebox" href="destination.htm?path=blabla">mainpage</a> Im using facebox() to load the destination.htm The problem is in my destination.htm,when im trying to hit an alert(window.location.href) im getting the mainpage.aspx and not the destination.htm.why ? all i want to do is to read the path from the page to get the querystring (but im getting the wrong path). thanks alot

Answers


That is because facebox is not actually redirecting the browser to that page, but fetching via ajax and injecting it into the facebox div on the same page.

You could try grabbing the href attribute of the anchor instead, perhaps something like:

var lastVisited = null;
var lastVisitedQS = null;
$("a[rel='facebox']").facebox()
          .click(function() {
              lastVisited = this.href;

              // you can extract the query string like this
              var a = document.createElement('a');
              a.href = lastVisited;
              lastVisitedQS = a.search; // should give path=blabla
          });

and then in your destination.htm do:

alert(lastVisited);
alert(lastVisitedQS);

Hope that helps!


You can use window.location.hostname to get host URL, window.location.pathname to get virtual dir+page and window.location.search to get querystring part of URL


Need Your Help

Fatal error: Class 'WP_Customize_Control' not found - WordPress

php wordpress wordpress-theming

Im building my own wordperss theme and when starting on the WordPress Customizer for theme options I have come in a little bit of trouble.

What drawing technology would be appropriate?

iphone ios cocoa-touch

I'm building an iOS application that will be drawing diagrams for the user to see and manipulate (move, add, remove elements) and I'm having trouble choosing how to implement the actual rendering.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.