alternatives to frames to include content from different servers - html

I need to make a series of webpages. Each with a header coming from a website, and the content coming from an html page in my dropbox/public. I simple way would be to use frames, but they are deprecated.
As the html content is of different size. So the iFrame does not seem to be the right tool.
What alternatives do I have?
Many people seemed to suggest in the comments ajax with jsonp. Unfortunately I am completely new to those methods, so I would need an example to copy and then work with.
Thanks,
Pietro

You need to have the Jquery library in the main page. Copy the above code on the header of your page:
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
The make a div with the response id:
<div id="response"></div>
JQuery has an AJAX function called "load", this function is appended to a selector where you want a page to be loaded, in this case we want to contents of file "exemple.html" to load in the tag with id "response".
<script>
$(document).ready(function(){
// load exemple page when the page loads
$("#response").load("exemple.html");
});
</script>
Also you can load the content when a link from the main page is clicked:
<script>
$("#exemple").click(function(){
// load exemple page on click
$("#response").load("exemple.html");
});
</script>
For this you have to add on your HTML code a link with the id="exemple"
Click to load the exemple page
Hope this helps you!

Related

Hide custom field depending on the page

I need to hide a custom field created by a theme only in a specific page.
I am using a code that works perfect in another site but in wordpress seems to not working and i can't spot why not. The code loads as far as i can see in source page. I have added the code directly into the theme header.php file and this is the code
<script type="text/javascript">
$(document).ready(function() {
if (window.location.href.indexOf("https://www.demosite.com/advanced-search/?adv_location=&bedrooms=&bathrooms=&filter_search_type%5B%5D=residential-land&filter_search_action%5B%5D=&price_low=0&price_max=9900000&submit=Search&elementor_form_id=18618") ){
$('#property-size-ft2').hide();
}
});
</script>
Ideal case would be to have the ability to create a custom advanced search per each page but this is not possible, that is why i created all the custom fields and now i want to fine some of them, depending on he actual page they are displayed.

How to embed a limesurvey survey in my HTML without iframe

I created a page to host some forms served by a limesurvey instance. For instance I used an iframe to embed them. But it created some problems. The worst is that in the second question group, which is smaller, the parent focus should go to the page top, otherwise the page appears clear because the form content was rendered on the top, and the iframe size was not resized.
Maybe it is just a limitation of mine dealing with iframe. But it would be nice if limesurvey offer other ways to embed surveys.
Any help is welcome.
I still don't know how to do it without Iframes on 2+ version.
The problem of multiple pages surveys standing on the bottom of the page can be handled with a small javascript workaround:
Edit the survey and add the following code at 'edit text elements' (toggle to 'source' mode at wysiwyg editor):
<a id="top" name="top"></a> <script type="text/javascript">
(function($) {
$(document).ready(function(e) {
window.location.hash = 'top';
});
})(jQuery);
</script>

Get code source of dynamically loaded HTML content (Chrome/Gmail)

I am trying to access the HTML code source of AJAX dynamically loaded content. How could I do it?
For example on Gmail, I am trying to access the HTML code of a given email discussion's content (the different entries of a given email discussion) which is loaded only when I click on this email discussion's line in the main list. The code source I can access is only the one of the page initially loaded (the list of all email discussions). Any idea?
Right-click on the page and select "Inspect Element". The element view is updated when JavaScript makes changes to the page, whereas the "View Source" view only shows content from when the page was loaded.
If you right click -> "View Source", it will show you the contents of a reloaded version of the page you are on.
Using "Inspect element" (hotkey CTRL+SHIFT+i) in Chrome shows the source of the dynamic content.
I think you want to bind event on the dom element that loaded after initial page load using ajax. If so then you can use jQuery library and you can use live method of jquery.
Here is a link for live method, you can check that.
http://api.jquery.com/live/
What you need
Download jquery latest library (http://docs.jquery.com/Downloading_jQuery)
and then include it in script within head
or you can use cdn http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
then do like following
<script>
$(document).ready(function(){
$("#ajax_dom_element_id").live('click_or_any_event',function(){
code snippet you wan dot
});
});
</script>
I think it will be helpfull.

How do I reuse parts of a webpage (using div)?

I have several HTML pages that share a menu area. Every time I update the menu area (eg with new "breaking news") I need to update all 10 pages manually.
With frames, they all point to same frame page so I only need to change one page. But I was told frames are bad and I should use divs. Is there a simple way to do this with divs? (preferably without JQuery or Ajax)
You could use an iframe. It still is sort of a frame, but you would avoid a frameset-index-page and if you set borders to 0 and content that fits in you won't even see borders or scroll-bars and it will behave like a div
<iframe style="border-width:0px;" src="news.html"/>
You should use fixed width-heights though to avoid scrollbars. To me its the simplest "html-only"-solution to your problem.
You could use jQuery's load() function.
You'd have to add the following to the head of each of your pages:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
Then you'd have to add the following DIV where you want the content to be loaded.
<div id="breakingNews"></div>
<script type="text/javascript" src="http://example.com/news.js"></script>
Be sure to edit the link to the news.js file.
Then you'd create the news.js on your server, and add the following code:
$('#breakingNews').load('path/to/breakingnews.html');
More about load():
http://api.jquery.com/load/
Not the nice solution, but if you really want to have single point of menu definition, include it in the script which includes setMenu function and you load the script in every page's head and call a setMenu function on every page's body onload, which then sets the menu as innerHTML of the div that you include in every page specifically as a menu placeholder.
Client side templating may be a solution if you are trying to avoid server side solutions for dynamically generating your content.
Using ICanHaz.js templating, http://icanhazjs.com/, you could store your html as objects. Then either include them directly as .js files, or make ajax requests for them.

one TMLH footer page to show all my web page

i am making side all pages static html
i want to make footer another page and i want to show all my web page
because when i have to make change in footer then i will have to change all of my web pages its so difficult i want when i change one page it will appear all pages
how can i do it please help me i am using html pages
Thank's
There is no way to use this using straight HTML - you will need some server side technology - PHP, ASP, Server Side Includes, etc.
Here is a pretty basic break down of some of the options. http://webdesign.about.com/od/ssi/a/aa052002a.htm
Sure no problem. when testing from your hardrive IE will bring the content in, google will not. from a website all browsers will work.
add this to the bottom of your html pages:
<span id="include_footer"></span>
then add a jquery ajax call to get the footer data and replace the span content in the head of html page:
<script type="text/javascript">
$(document).ready(function () {
//include the footer html
$.ajax({
url:"footer.html",
context: document.body,
success: function(response){
$("#include_footer").html(response);
},
error: function(response) {
alert('error loading file');
}
});
});
</script>
Enjoy :)
I see that you're using HTML. Have you considered using PHP? All you need to do is change your page to .php instead of .html and you have a php page. Now, if you make a page, say footer.php, on each of your pages your can add this line:
<?php include 'my/file/path/footer.php'; ?>
Anything that you have in your footer.php file will be included in that page.
Common web servers allows you to prepend or append contents to all pages on particular web app.
For instance in IIS, you can select a an html file for every document you web server returns:
it could be found in the IIS website/app properties then in Documents tab.
For Apache Server:
http://perl.guru.org/scott/hobbies/apache/
For purely static HTML, some IDEs can handle this effectively. In Dreamweaver, you can create a template that your site will use. This template can include an editable section and a non-editable section that contains your footer. You then create pages based on this template. When you update the template, Dreamweaver will handle updating all other pages on your site that are based on that template.
Edit: This is an example of a template in Dreamweaver that I made a couple years back for a group project.
The Bobs (Screenshot)
The area surrounded by the blue-green rectangle is the editable region (for pages created based on this template).