开发者

How to link to parent site (ie index.html) from a page that has been loaded into a div using .load()

This must be a quite common thing to do but I can't find any answers.

Our parent document is called index.html. In this document we have a button, and two divs.

One called #pitch, one called #header.

When button is pressed jQuery loads contact.html into #pitch. Something like this:

$(button).click(function() {
   $("#pitch").load("contact.html");
});

So far everything good. But now, how do I create a link inside contact.html (which now is the child) to #header which is inside the parent document?

ie:

$(SomeThingInContact.Html).click(function() {
   $("#header").text("new text");

});
</script>

UPDATE:

According to the answ开发者_开发百科ers yet maybe my questions has been unclear.

The problem is that the contact.html that is loaded into the div #pitch doesn't know about it's parent document index.html. But I want to make changes FROM contact.html TO #header which is in index.html

I've tried top.getElementById("header"). Also tried window.document.parent.getElementById.

Of what I understand these only work with iFrames, or?

Thanx


Try to find this guy before you use .text

$("#header").text("new text");

$("#header").find("#elementtofind").text("new text");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜