Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

How to parse this page's URL

  Asked By: Caitlin    Date: Jun 27    Category: Sharepoint    Views: 7414

I currently have a cute little feature that I run in javascript in a
Content Editor Web Part. I would like to be able to pass a value in as
part of the URL and be able to get my hands on that value in javascript.


I do have FrontPage 2003 and Do Not have .NET.

Can I somehow end up knowing the value of 'Color' in my javascript?



2 Answers Found

Answer #1    Answered By: Titus Sweet     Answered On: Jun 27

You could look at the document.location.href and parse  it out.

Here is some UNTESTED javascript  that may help.

var laURL = document.location.href.split('?');
if (laURL.length==2)
var laParams = laURL[1].split('&');
for (var LCV=0; LCV < laParams.length; LCV++)
var laKeyValue = laParams[LCV].split('=');
if (laKeyValue.length==2)
var lsKey = laKeyValue[0];
var lsValue = laKeyValue[1];
if (lsKey=='Color)
alert('Found the color ' + lsValue);

Answer #2    Answered By: Jagdish Joshi     Answered On: Jun 27

The Content Editor Web Part renders based on the Source or the link to the source. If you have a URL in your source or you are linking to the source, you will already know ?color=red

Could you please provide more details about exactly what you are trying to accomplish.

Didn't find what you were looking for? Find more on How to parse this page's URL Or get search suggestion and latest updates.