0

I have a site with a toolbar at the top. this toolbar has a dropdown. When user selects the dropdown, based on the selection, the whole page is refreshed to show new data.

The toolbar is part of the website code (HTML).

Question - Now I want to have this toolbar separated from the website code since this toolbar is going to be included for other html as well. I was thinking of have the toolbar code as iframe. Is this a good idea? what are the challenges and how to include the new iframe in other websites, is ti challenging?

Any other options other than an iframe?

anand patil
  • 467
  • 1
  • 9
  • 24

2 Answers2

1

You can and should use AJAX for this.

Have a webpage with HTML (Lets call this page1):

<h1>Hello world! And tool bar code is on this page...</h1>

Then in your main HTML file call the page1 using AJAX (Read more about ajax here) and append it to your html code how ever you would like.

Bubble Hacker
  • 4,622
  • 1
  • 12
  • 19
0

The best thing to do is to take advantage of the server-side language you're using to include the script (say toolbar.html) for your toolbar. If you want to load the part of your page that should be refreshed asynchronously, just id that part and do so using javascript.

Nicholas Kajoh
  • 1,022
  • 2
  • 16
  • 27