Jaap Vossers' SharePoint Blog

Just another WordPress.com site

Archive for the ‘SharePoint 2013 Apps’ Category

Getting query string values in JavaScript

leave a comment »

With the introduction of the new SharePoint 2013 App Model, many SharePoint Developers will have to get their hands dirty writing JavaScript. One operation that is going to be very common is to read query string values from JavaScript. C# Developers are used to things like HttpContext.Current.Request.QueryString[“param1”], but unfortunately it is slightly more complicated to get the same result in JavaScript.

Searching the web for an answer on how to do this in JavaScript yields many different results. I would say that the best suggestions are listed on this popular question on StackOverflow. The most upvoted answer to this StackOverflow question has been improved by James Padolsey which has lead to the following function:

function getParameterByName(name) {

    var match = RegExp('[?&]' + name + '=([^&]*)')

    return match ?
        decodeURIComponent(match[1].replace(/\+/g, ' '))
        : null;


This is my favourite solution as it’s brief, readable, and it works 🙂




Written by jvossers

August 30, 2012 at 11:18 am

Hyperlinks with target=”_blank” inside SharePoint 2013 ClientWebPart blocked in Chrome

leave a comment »

Recently I have been playing a bit with the new SharePoint 2013 App model. I was using the new Napa tools to develop a little App that could be be hosted in an App Part, also known as ClientWebPart, which is essentially an iframe which loads your App.

My App consisted of an ASPX page with a bunch of hyperlinks with target=”_blank” on them. I noticed that when the ASPX page was loaded by the ClientWebPart in its iframe, the hyperlinks wouldn’t work at all in Chrome (Firefox and IE were fine!). I started inspecting the DOM and noticed a “sandbox” attribute on the iframe element.

The sandbox attribute rendered on the ClientWebPart iframe contains the following four options:

  • allow-forms
  • allow-scripts
  • allow-same-origin
  • allow-top-navigation

After a bit of research, I found that adding the “allow-popups” option unblocks the hyperlinks.

I would say that this is a bug in the ClientWebPart, as Chrome appears to be the only browser affected. Let’s hope this will be fixed soon! In the meantime, consider using target=”_top” as an alternative, as this does work.

Written by jvossers

August 28, 2012 at 5:03 pm