English 中文(简体)
• 如何将正确的斜体带上一流?
原标题:How to pass correct urls to iframe page?

The URLs such as below are support on my website:

(1) http://mysite.example.com/section/ - main page
(2) http://mysite.example.com/section/#page2
(3) http://mysite.example.com/section/surname-name-middlename/
(4) http://mysite.example.com/section/surname-name-middlename/#page2
(5) http://mysite.example.com/section/add

现在,我正试图在另一个地点展示我的场地。 该网址支持<条码>低浓度/代码>和<条码> 改变方法,界定散草,并在变后作出反应。

I ve defined setLocation for all pages, no problem here. 因此,上述三党网站链接如下:

(1) http://3rdpartysite.com/mypage
(2) http://3rdpartysite.com/mypage#page2
(3) http://3rdpartysite.com/mypage#surname-name-middlename
(4) http://3rdpartysite.com/mypage#surname-name-middlename,page2
(5) http://3rdpartysite.com/mypage#add

但现在,我试图执行正确的行为。

<代码><>>条/代码>是所有网页的共同部分。

我试图在主页上做以下工作(而不是上文选择(4)):

// location here is everything after # in url: http://3rdpartysite.com/mypage#...
function onLocationChanged(location) { 
  if (location.indexOf( page )>-1) {
    window.location.href =  # +location;
  } else if (location ==  add ) {
      window.location.href = window.location.host + window.location.pathname +  /add ;
    } else if (location !=   ) {
        window.location.href = window.location.host + window.location.pathname +  / +location+ / ;
      }
}

但它没有适当开展工作。 我的做法有什么错误?

最佳回答

该守则在主要网页上适当运作:

function onLocationChanged(loc) {
    var url = window.location.protocol +  //  + window.location.host + window.location.pathname;
    if (loc.indexOf( page ) > -1 && loc.indexOf( ,page ) == -1) {
        window.location.href =  #  + loc;
    } else if (loc ==  add ) {
        window.location.href = url +  add ;
    } else if (loc !=    && loc.indexOf( ,page ) > -1) {
        window.location.href = url +    + loc.split( , , 2)[0] +  /#  + loc.split( , , 2)[1];
    } else if (loc !=   ) {
        window.location.href = url +    + loc +  / ;
    }
}

这里是其他网页的代码(无选择(4)支持):

function onLocationChanged(loc) {
  var url = window.location.protocol +  //  + window.location.host +  /  + window.location.pathname.split( / ,3)[1] +  / ;
  if (loc.indexOf( page )>-1) {
    window.location.href = url +  #  + loc;
  } else if (loc ==  add ) {
      window.location.href = url +  add ;
    } else if (loc !=   ) {
        window.location.href = url +    + loc +  / ;
      }
}

Don t知道如何使它变得司空见惯。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签