Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

Edited Issue: SPGetCurrentSite() fails when page URL has hash anchor (ex.:page.aspx#hashToken=value) [10104]

$
0
0
From: http://spservices.codeplex.com/discussions/398175

Hi Marc...

Came across an issue with SPGetCurrentSite() utility... Looks like it is not setup to strip out any url hash information, which in some cases (mine in this case) generates invalid XML and thus the call to the server fails... Here is an example that recreates
the issue:

Add the following to the end of a SP page: yoursite/page.aspx#focus=myelement&show=tab1

The problem in SPGetCurrentSite() is that it currently strips out the search params (anything after the ?), but is not accounting for an URL that has only Hash information (example above).

The code that I think needs to be modified is at line 1273:




var msg = SOAPEnvelope.header +
"<WebUrlFromPageUrl xmlns='" + SCHEMASharePoint + "/soap/' ><pageUrl>" +
((location.href.indexOf("?") > 0) ? location.href.substr(0, location.href.indexOf("?")) : location.href) +
"</pageUrl></WebUrlFromPageUrl>" +
SOAPEnvelope.footer;




In my projects I have used something like the following to ensure I get a "pure" page url:





var pageUrl = location.href;
if (location.search.length > 0) {
pageUrl = location.href.substr(0, location.href.indexOf(location.search));
} else if (location.hash.length > 0) {
pageUrl = location.href.substr(0, location.href.indexOf(location.hash));
}






In this most recent customization I did, I'm using the URL hash to store information (with format of key=value&key2=value2) that reflects the current state of the page, so that users can use the URL to send to others in the company, thus enabling
those other users to see exactly what user 1 was seeing/referencing.

Paul.

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>