-1

I have index page that contains items i want to keep on all the pages. And i have iframe in the middle of the index page, where all the content is shown.

<iframe id="midfr" src="news.html"></iframe>

When clicking on links, content goes to midfr, while website url is always like www.example.com/ Is there a way to have urls like www.example.com/iframe_url/ when going to specified page using iframes? I dont even have a clue on how to do that.

However ive seen some websites that have some constant divs, while main content blinks on visiting links. Although their source code didnt include any iframes..

lolbas
  • 794
  • 1
  • 9
  • 34
  • Is the content all from the same domain? – Malk Jun 16 '14 at 16:50
  • You could try combining http://stackoverflow.com/questions/2429045/iframe-src-change-event-detection with https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_replaceState().C2.A0method – Malk Jun 16 '14 at 18:31

1 Answers1

0

No, because iframes don't provide any events to the DOM that you can use to change the URL.

Even if your write it as a method to capture and execute the event. You will still not get it. Because it is not allowed.

Iframe won't provide control over any event, untill the code to handle the event is already a part of it.

You can change the Website's URL using History PushState method. But only if you can have an event to do that. Since iframes don't provide you with an event you won't be able to change the URL.

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103
  • ok, well, and is there a way to change content of
    element? i mean to refresh only specified divs' content keeping rest content the same?
    – lolbas Jun 16 '14 at 16:50
  • Why don't you just use php includes to create a page template? – Adi Bradfield Jun 16 '14 at 16:52
  • Yes, use this `$('div').html('new content's html here');`. You can use some specific selector to change the content of a specific div. – Afzaal Ahmad Zeeshan Jun 16 '14 at 16:53
  • Thanks Adi and Afzaal, thats kind of what i was looking for :) Just for those who will look this page, found nice tut [here](http://www.willmaster.com/library/web-development/replace-div-content.php) – lolbas Jun 16 '14 at 17:07