Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am attempting to open a popup dialog box, that popup should then open a video library page.

The code works fine on the root site level (e.g. http://hostName:8084/pages/abc.aspx), but when I use the same code for child web (e.g. http://hostName:8084/SomeSite/Pages/abc.aspx) then my popup doesn't open.

I am using this code to open my dialog box:

function OpenDialog(listname, id, width, height) {

    this.ctx = new SP.ClientContext();
    this.sitecoll = this.ctx.get_site();
    this.web = this.sitecoll.get_rootWeb();
    this.ctx.load(this.web);
    this.itemid = id;
    this.listname = listname;
    this.dialogwidth = width;
    this.dialogheight = height;
    this.list = web.get_lists().getByTitle(listname);
    var query = new SP.CamlQuery();
    query.set_viewXml("<View/>");
    this.listItems = this.list.getItems(query);

    this.ctx.load(this.list);
    this.ctx.load(this.listItems);

    ctx.executeQueryAsync(
            Function.createDelegate(this, this.onSuccess),
            Function.createDelegate(this, this.onFail)
        );
}

In a child web this code doesn't use the root site address (e.g. http://hostName:8084).

Is there a way to get the root site address to open the list in the site collection?


Sorry, My system cache was full and I guess it was taking some files from there so this code was not working.. I cleared my cache and created a new site collection. After that I deployed my solution again and it worked. Thanks for everyone's help..

share|improve this question

closed as too localized by SPDoctor, Alex Angas Aug 5 '11 at 22:06

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

Use the Url property of the SP.Site.

Gets the full URL to the root Web site of the site collection, including host name, port number, and path.

http://msdn.microsoft.com/en-us/library/ee550732.aspx

share|improve this answer
Hi Rob, I am inside site collection level and I am having a list which is at the top root level. I want to put some value inside that.. I am using this.ctx = new SP.ClientContext(); this.sitecoll = this.ctx.get_site(); this.web = this.sitecoll.get_rootWeb(); to get the root web but it is returning me the site collection only.. :( .. I tried your solution as well but it didn't help me.. :( – Ankit Jul 13 '11 at 9:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.