Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7077201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:23:35+00:00 2026-05-28T06:23:35+00:00

The URLs like below are supported on my site: (1) http://mysite.example.com/section/ – main page

  • 0

The URLs like below are supported on my site:

(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

Now I am trying to show my site as iframe on another site. That site supports setLocation and onLocationChanged methods to define hash and react when hash is changed accordingly.

I’ve defined setLocation for all pages, no problem here. So, links above at 3rd party site look like below:

(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

But now I am trying to implement correct onLocationChanged behaviour.

section is common part for all pages.

I’ve tried to do the following at the main page (and not supporting option (4) above):

// 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+'/';
      }
}

But it doesn’t work properly. What is wrong with my approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:23:35+00:00Added an answer on May 28, 2026 at 6:23 am

    Here is the code working properly at the main page:

    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 + '/';
        }
    }
    

    and here is the code for other pages (without option (4) support):

    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 know how to make it common.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array in PHP with URLs like below: http://example.com/apps/1235554/ http://example.com/apps/apple/ http://example.com/apps/126734 http://example.com/images/a.jpg
I use the below mod rewrite code for urls like: www.site.com/play/543 RewriteEngine On RewriteRule
I have a site with URLs like this: http://domain.co.uk/subdir/page.php I have redesigned the site
I have some urls like these below http://www.bla-bla.com/hello-world/blah/1345346-asfasdf.html http://www.bla-bla.com/hello-world/454536556-asdf-rtrthr-dssdfg.html http://www.bla-bla.com/hello-world/bla/how/what/26609768-nmbbasdf.html IF the url has
I am trying to setup a mod rewrite rule to change urls like: http://www.site.com/play/4435
I'm trying to implement urls like the one below: www.example.com/contact-us ,but with one exception,
want to rewrite urls like site.com/software to wp-content/themes/dir/software.php and something is not working.. Here's
Is there some way I can use URLs like: http://www.blog.com/team-spirit/ instead of http://www.blog.com/?p=122 in
I'm developing a site which has urls like this: site.com/james site.com/james/photos Schema for this
I'm trying to create tiny urls like this: site.com/abc123 goes to: site.com/index.php?token=abc123 but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.