How to get the source of the .load() url
Once I do $("#obj").load(url)
is there a way to get the loaded url from #obj
?
jquery
add a comment |
Once I do $("#obj").load(url)
is there a way to get the loaded url from #obj
?
jquery
add a comment |
Once I do $("#obj").load(url)
is there a way to get the loaded url from #obj
?
jquery
Once I do $("#obj").load(url)
is there a way to get the loaded url from #obj
?
jquery
jquery
asked Feb 13 '12 at 6:32


Control FreakControl Freak
7,7992072129
7,7992072129
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
That code will just load the contents of #obj
in the DOM using the results of a call to url
. jQuery will not store the url anywhere. But you can manually store the data and attach it to the dom object using data()
. Like this:
$("#obj").load(url).data('url', url);
You can then later retrieve the url like this:
var url = $("#obj").data('url');
See http://api.jquery.com/data/ for details.
I would like to retrieve the content of the jquery .load() function. I did not know how to get it. I used your example, and it worked like a charm. However, I wonder, there is no a more elegant solution to get the loaded content of the load function? e.g. var load_content = .load() ....retrieve( load_content)? or '.data(load(url content ) ) '? Thanks @Ben Lee
– Elias EstatisticsEU
Nov 5 '18 at 16:16
1
I'm not sure I follow your question completely...load
already retrieves the content (that's what it does) and injects into the element. To later analyze the contents, you can just look at the contents of the element (using.html()
,.text()
, or.contents()
depending on the form of the content you want)
– Ben Lee
Nov 5 '18 at 16:33
Sorry Ben for not explaining clearly: The same url is repeated 3 times. This can be avoided?$(document).ready(function(){ $(" $("#idR_Code_PSPP").click(function(){ $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en") var url_idR_Code_PSPP = url
– Elias EstatisticsEU
Nov 5 '18 at 21:03
*Sorry for misunderstanding. I mean: "content = the url". The url is repeated three times: in .load(), in data(), and in var url = data(url).... So this repeat process can be avoided e.g. var load_content = .load() in order to retrieve the url, not the content. :)
– Elias EstatisticsEU
Nov 5 '18 at 21:09
1
There's no more elegant way that I know of.
– Ben Lee
Nov 6 '18 at 0:47
add a comment |
Here it is an actual example, that It uses Language selection, together with loading content using Jquery syntax:
In the body:
<a href="index.html" class="topnav_estatistics">ESTATISTICS </a>
<a id="idStatistics" href ="#Statistics" > <span lang="en">Statistics </span> <span lang="gr">Στατιστική </span> </a>
<a id="idR_Code_PSPP" href ="#R_Code_PSPP" > <span lang="en">R Code / PSPP </span> <span lang="gr"> R Code / PSPP </span> </a>
<a id="idStat_Article" href ="#Stat_Article" > <span lang="en">Stat Articles </span> <span lang="gr"> Άρθρα </span> </a>
<a id="idPlanets_Health" href ="#Planets_Health" > <span lang="en">Planet's Health </span> <span lang="gr"> Περιβάλλον </span> </a>
<a id="idServices" href ="#Services" > <span lang="en">Services </span> <span lang="gr"> Υπηρεσίες </span> </a>
<!--- The Language options --->
<select id="lang_switch" class="lang_switch">
<option value="en">En </option>
<option value="gr">Gr </option>
</select>
The div section where external html pages div-specific content is loaded.
<div id="mainbody" class="main_body"> </div>
<div id="mainbody_2" class="main_body"> </div>
<div id="mainbody_3" class="main_body"> </div>
The language selection together with the Jquery document load of external html div-specific content on specific div section of the current page.
<script>
// stackoverflow: 49637061 & 11134701
$('[lang="en"]').show();
$('[lang="gr"]').hide();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
$('#lang_switch').change(function () {
var lang = $(this).val();
switch (lang) {
case 'gr':
$('[lang]').hide();
$('[lang="gr"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
$("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
$("#left_link_index").load("Statistics.html #left_links_gr")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
$("#left_link_index").load("Services.html #left_links_gr");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_gr', function(){
$("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
var url_bio_history_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
$("#mainbody_2").html(url_bio_history_gr)
});
$(document).on('click', '#id_info_gr', function(){
$("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
var url_info_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
$("#mainbody_2").html(url_info_gr)
});
});
break;
case 'en':
$('[lang]').hide();
$('[lang="en"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
break;
};
});
</script>
The External HTML file must have a div section named e.g.
<div id="info_gr" class="info_services" > and/or
<div id="info_en" class="info_services" > or
<div id="bio_history_en" class="biohistory" > and/or
<div id="bio_history_gr" class="biohistory" >
The script goes exactly before the end, specifically exactly before "</html>".
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9256423%2fhow-to-get-the-source-of-the-load-url%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
That code will just load the contents of #obj
in the DOM using the results of a call to url
. jQuery will not store the url anywhere. But you can manually store the data and attach it to the dom object using data()
. Like this:
$("#obj").load(url).data('url', url);
You can then later retrieve the url like this:
var url = $("#obj").data('url');
See http://api.jquery.com/data/ for details.
I would like to retrieve the content of the jquery .load() function. I did not know how to get it. I used your example, and it worked like a charm. However, I wonder, there is no a more elegant solution to get the loaded content of the load function? e.g. var load_content = .load() ....retrieve( load_content)? or '.data(load(url content ) ) '? Thanks @Ben Lee
– Elias EstatisticsEU
Nov 5 '18 at 16:16
1
I'm not sure I follow your question completely...load
already retrieves the content (that's what it does) and injects into the element. To later analyze the contents, you can just look at the contents of the element (using.html()
,.text()
, or.contents()
depending on the form of the content you want)
– Ben Lee
Nov 5 '18 at 16:33
Sorry Ben for not explaining clearly: The same url is repeated 3 times. This can be avoided?$(document).ready(function(){ $(" $("#idR_Code_PSPP").click(function(){ $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en") var url_idR_Code_PSPP = url
– Elias EstatisticsEU
Nov 5 '18 at 21:03
*Sorry for misunderstanding. I mean: "content = the url". The url is repeated three times: in .load(), in data(), and in var url = data(url).... So this repeat process can be avoided e.g. var load_content = .load() in order to retrieve the url, not the content. :)
– Elias EstatisticsEU
Nov 5 '18 at 21:09
1
There's no more elegant way that I know of.
– Ben Lee
Nov 6 '18 at 0:47
add a comment |
That code will just load the contents of #obj
in the DOM using the results of a call to url
. jQuery will not store the url anywhere. But you can manually store the data and attach it to the dom object using data()
. Like this:
$("#obj").load(url).data('url', url);
You can then later retrieve the url like this:
var url = $("#obj").data('url');
See http://api.jquery.com/data/ for details.
I would like to retrieve the content of the jquery .load() function. I did not know how to get it. I used your example, and it worked like a charm. However, I wonder, there is no a more elegant solution to get the loaded content of the load function? e.g. var load_content = .load() ....retrieve( load_content)? or '.data(load(url content ) ) '? Thanks @Ben Lee
– Elias EstatisticsEU
Nov 5 '18 at 16:16
1
I'm not sure I follow your question completely...load
already retrieves the content (that's what it does) and injects into the element. To later analyze the contents, you can just look at the contents of the element (using.html()
,.text()
, or.contents()
depending on the form of the content you want)
– Ben Lee
Nov 5 '18 at 16:33
Sorry Ben for not explaining clearly: The same url is repeated 3 times. This can be avoided?$(document).ready(function(){ $(" $("#idR_Code_PSPP").click(function(){ $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en") var url_idR_Code_PSPP = url
– Elias EstatisticsEU
Nov 5 '18 at 21:03
*Sorry for misunderstanding. I mean: "content = the url". The url is repeated three times: in .load(), in data(), and in var url = data(url).... So this repeat process can be avoided e.g. var load_content = .load() in order to retrieve the url, not the content. :)
– Elias EstatisticsEU
Nov 5 '18 at 21:09
1
There's no more elegant way that I know of.
– Ben Lee
Nov 6 '18 at 0:47
add a comment |
That code will just load the contents of #obj
in the DOM using the results of a call to url
. jQuery will not store the url anywhere. But you can manually store the data and attach it to the dom object using data()
. Like this:
$("#obj").load(url).data('url', url);
You can then later retrieve the url like this:
var url = $("#obj").data('url');
See http://api.jquery.com/data/ for details.
That code will just load the contents of #obj
in the DOM using the results of a call to url
. jQuery will not store the url anywhere. But you can manually store the data and attach it to the dom object using data()
. Like this:
$("#obj").load(url).data('url', url);
You can then later retrieve the url like this:
var url = $("#obj").data('url');
See http://api.jquery.com/data/ for details.
answered Feb 13 '12 at 6:36
Ben LeeBen Lee
43.6k9109139
43.6k9109139
I would like to retrieve the content of the jquery .load() function. I did not know how to get it. I used your example, and it worked like a charm. However, I wonder, there is no a more elegant solution to get the loaded content of the load function? e.g. var load_content = .load() ....retrieve( load_content)? or '.data(load(url content ) ) '? Thanks @Ben Lee
– Elias EstatisticsEU
Nov 5 '18 at 16:16
1
I'm not sure I follow your question completely...load
already retrieves the content (that's what it does) and injects into the element. To later analyze the contents, you can just look at the contents of the element (using.html()
,.text()
, or.contents()
depending on the form of the content you want)
– Ben Lee
Nov 5 '18 at 16:33
Sorry Ben for not explaining clearly: The same url is repeated 3 times. This can be avoided?$(document).ready(function(){ $(" $("#idR_Code_PSPP").click(function(){ $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en") var url_idR_Code_PSPP = url
– Elias EstatisticsEU
Nov 5 '18 at 21:03
*Sorry for misunderstanding. I mean: "content = the url". The url is repeated three times: in .load(), in data(), and in var url = data(url).... So this repeat process can be avoided e.g. var load_content = .load() in order to retrieve the url, not the content. :)
– Elias EstatisticsEU
Nov 5 '18 at 21:09
1
There's no more elegant way that I know of.
– Ben Lee
Nov 6 '18 at 0:47
add a comment |
I would like to retrieve the content of the jquery .load() function. I did not know how to get it. I used your example, and it worked like a charm. However, I wonder, there is no a more elegant solution to get the loaded content of the load function? e.g. var load_content = .load() ....retrieve( load_content)? or '.data(load(url content ) ) '? Thanks @Ben Lee
– Elias EstatisticsEU
Nov 5 '18 at 16:16
1
I'm not sure I follow your question completely...load
already retrieves the content (that's what it does) and injects into the element. To later analyze the contents, you can just look at the contents of the element (using.html()
,.text()
, or.contents()
depending on the form of the content you want)
– Ben Lee
Nov 5 '18 at 16:33
Sorry Ben for not explaining clearly: The same url is repeated 3 times. This can be avoided?$(document).ready(function(){ $(" $("#idR_Code_PSPP").click(function(){ $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en") var url_idR_Code_PSPP = url
– Elias EstatisticsEU
Nov 5 '18 at 21:03
*Sorry for misunderstanding. I mean: "content = the url". The url is repeated three times: in .load(), in data(), and in var url = data(url).... So this repeat process can be avoided e.g. var load_content = .load() in order to retrieve the url, not the content. :)
– Elias EstatisticsEU
Nov 5 '18 at 21:09
1
There's no more elegant way that I know of.
– Ben Lee
Nov 6 '18 at 0:47
I would like to retrieve the content of the jquery .load() function. I did not know how to get it. I used your example, and it worked like a charm. However, I wonder, there is no a more elegant solution to get the loaded content of the load function? e.g. var load_content = .load() ....retrieve( load_content)? or '.data(load(url content ) ) '? Thanks @Ben Lee
– Elias EstatisticsEU
Nov 5 '18 at 16:16
I would like to retrieve the content of the jquery .load() function. I did not know how to get it. I used your example, and it worked like a charm. However, I wonder, there is no a more elegant solution to get the loaded content of the load function? e.g. var load_content = .load() ....retrieve( load_content)? or '.data(load(url content ) ) '? Thanks @Ben Lee
– Elias EstatisticsEU
Nov 5 '18 at 16:16
1
1
I'm not sure I follow your question completely...
load
already retrieves the content (that's what it does) and injects into the element. To later analyze the contents, you can just look at the contents of the element (using .html()
, .text()
, or .contents()
depending on the form of the content you want)– Ben Lee
Nov 5 '18 at 16:33
I'm not sure I follow your question completely...
load
already retrieves the content (that's what it does) and injects into the element. To later analyze the contents, you can just look at the contents of the element (using .html()
, .text()
, or .contents()
depending on the form of the content you want)– Ben Lee
Nov 5 '18 at 16:33
Sorry Ben for not explaining clearly: The same url is repeated 3 times. This can be avoided?
$(document).ready(function(){ $(" $("#idR_Code_PSPP").click(function(){ $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en") var url_idR_Code_PSPP = url
– Elias EstatisticsEU
Nov 5 '18 at 21:03
Sorry Ben for not explaining clearly: The same url is repeated 3 times. This can be avoided?
$(document).ready(function(){ $(" $("#idR_Code_PSPP").click(function(){ $("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en") var url_idR_Code_PSPP = url
– Elias EstatisticsEU
Nov 5 '18 at 21:03
*Sorry for misunderstanding. I mean: "content = the url". The url is repeated three times: in .load(), in data(), and in var url = data(url).... So this repeat process can be avoided e.g. var load_content = .load() in order to retrieve the url, not the content. :)
– Elias EstatisticsEU
Nov 5 '18 at 21:09
*Sorry for misunderstanding. I mean: "content = the url". The url is repeated three times: in .load(), in data(), and in var url = data(url).... So this repeat process can be avoided e.g. var load_content = .load() in order to retrieve the url, not the content. :)
– Elias EstatisticsEU
Nov 5 '18 at 21:09
1
1
There's no more elegant way that I know of.
– Ben Lee
Nov 6 '18 at 0:47
There's no more elegant way that I know of.
– Ben Lee
Nov 6 '18 at 0:47
add a comment |
Here it is an actual example, that It uses Language selection, together with loading content using Jquery syntax:
In the body:
<a href="index.html" class="topnav_estatistics">ESTATISTICS </a>
<a id="idStatistics" href ="#Statistics" > <span lang="en">Statistics </span> <span lang="gr">Στατιστική </span> </a>
<a id="idR_Code_PSPP" href ="#R_Code_PSPP" > <span lang="en">R Code / PSPP </span> <span lang="gr"> R Code / PSPP </span> </a>
<a id="idStat_Article" href ="#Stat_Article" > <span lang="en">Stat Articles </span> <span lang="gr"> Άρθρα </span> </a>
<a id="idPlanets_Health" href ="#Planets_Health" > <span lang="en">Planet's Health </span> <span lang="gr"> Περιβάλλον </span> </a>
<a id="idServices" href ="#Services" > <span lang="en">Services </span> <span lang="gr"> Υπηρεσίες </span> </a>
<!--- The Language options --->
<select id="lang_switch" class="lang_switch">
<option value="en">En </option>
<option value="gr">Gr </option>
</select>
The div section where external html pages div-specific content is loaded.
<div id="mainbody" class="main_body"> </div>
<div id="mainbody_2" class="main_body"> </div>
<div id="mainbody_3" class="main_body"> </div>
The language selection together with the Jquery document load of external html div-specific content on specific div section of the current page.
<script>
// stackoverflow: 49637061 & 11134701
$('[lang="en"]').show();
$('[lang="gr"]').hide();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
$('#lang_switch').change(function () {
var lang = $(this).val();
switch (lang) {
case 'gr':
$('[lang]').hide();
$('[lang="gr"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
$("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
$("#left_link_index").load("Statistics.html #left_links_gr")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
$("#left_link_index").load("Services.html #left_links_gr");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_gr', function(){
$("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
var url_bio_history_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
$("#mainbody_2").html(url_bio_history_gr)
});
$(document).on('click', '#id_info_gr', function(){
$("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
var url_info_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
$("#mainbody_2").html(url_info_gr)
});
});
break;
case 'en':
$('[lang]').hide();
$('[lang="en"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
break;
};
});
</script>
The External HTML file must have a div section named e.g.
<div id="info_gr" class="info_services" > and/or
<div id="info_en" class="info_services" > or
<div id="bio_history_en" class="biohistory" > and/or
<div id="bio_history_gr" class="biohistory" >
The script goes exactly before the end, specifically exactly before "</html>".
add a comment |
Here it is an actual example, that It uses Language selection, together with loading content using Jquery syntax:
In the body:
<a href="index.html" class="topnav_estatistics">ESTATISTICS </a>
<a id="idStatistics" href ="#Statistics" > <span lang="en">Statistics </span> <span lang="gr">Στατιστική </span> </a>
<a id="idR_Code_PSPP" href ="#R_Code_PSPP" > <span lang="en">R Code / PSPP </span> <span lang="gr"> R Code / PSPP </span> </a>
<a id="idStat_Article" href ="#Stat_Article" > <span lang="en">Stat Articles </span> <span lang="gr"> Άρθρα </span> </a>
<a id="idPlanets_Health" href ="#Planets_Health" > <span lang="en">Planet's Health </span> <span lang="gr"> Περιβάλλον </span> </a>
<a id="idServices" href ="#Services" > <span lang="en">Services </span> <span lang="gr"> Υπηρεσίες </span> </a>
<!--- The Language options --->
<select id="lang_switch" class="lang_switch">
<option value="en">En </option>
<option value="gr">Gr </option>
</select>
The div section where external html pages div-specific content is loaded.
<div id="mainbody" class="main_body"> </div>
<div id="mainbody_2" class="main_body"> </div>
<div id="mainbody_3" class="main_body"> </div>
The language selection together with the Jquery document load of external html div-specific content on specific div section of the current page.
<script>
// stackoverflow: 49637061 & 11134701
$('[lang="en"]').show();
$('[lang="gr"]').hide();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
$('#lang_switch').change(function () {
var lang = $(this).val();
switch (lang) {
case 'gr':
$('[lang]').hide();
$('[lang="gr"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
$("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
$("#left_link_index").load("Statistics.html #left_links_gr")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
$("#left_link_index").load("Services.html #left_links_gr");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_gr', function(){
$("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
var url_bio_history_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
$("#mainbody_2").html(url_bio_history_gr)
});
$(document).on('click', '#id_info_gr', function(){
$("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
var url_info_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
$("#mainbody_2").html(url_info_gr)
});
});
break;
case 'en':
$('[lang]').hide();
$('[lang="en"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
break;
};
});
</script>
The External HTML file must have a div section named e.g.
<div id="info_gr" class="info_services" > and/or
<div id="info_en" class="info_services" > or
<div id="bio_history_en" class="biohistory" > and/or
<div id="bio_history_gr" class="biohistory" >
The script goes exactly before the end, specifically exactly before "</html>".
add a comment |
Here it is an actual example, that It uses Language selection, together with loading content using Jquery syntax:
In the body:
<a href="index.html" class="topnav_estatistics">ESTATISTICS </a>
<a id="idStatistics" href ="#Statistics" > <span lang="en">Statistics </span> <span lang="gr">Στατιστική </span> </a>
<a id="idR_Code_PSPP" href ="#R_Code_PSPP" > <span lang="en">R Code / PSPP </span> <span lang="gr"> R Code / PSPP </span> </a>
<a id="idStat_Article" href ="#Stat_Article" > <span lang="en">Stat Articles </span> <span lang="gr"> Άρθρα </span> </a>
<a id="idPlanets_Health" href ="#Planets_Health" > <span lang="en">Planet's Health </span> <span lang="gr"> Περιβάλλον </span> </a>
<a id="idServices" href ="#Services" > <span lang="en">Services </span> <span lang="gr"> Υπηρεσίες </span> </a>
<!--- The Language options --->
<select id="lang_switch" class="lang_switch">
<option value="en">En </option>
<option value="gr">Gr </option>
</select>
The div section where external html pages div-specific content is loaded.
<div id="mainbody" class="main_body"> </div>
<div id="mainbody_2" class="main_body"> </div>
<div id="mainbody_3" class="main_body"> </div>
The language selection together with the Jquery document load of external html div-specific content on specific div section of the current page.
<script>
// stackoverflow: 49637061 & 11134701
$('[lang="en"]').show();
$('[lang="gr"]').hide();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
$('#lang_switch').change(function () {
var lang = $(this).val();
switch (lang) {
case 'gr':
$('[lang]').hide();
$('[lang="gr"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
$("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
$("#left_link_index").load("Statistics.html #left_links_gr")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
$("#left_link_index").load("Services.html #left_links_gr");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_gr', function(){
$("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
var url_bio_history_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
$("#mainbody_2").html(url_bio_history_gr)
});
$(document).on('click', '#id_info_gr', function(){
$("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
var url_info_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
$("#mainbody_2").html(url_info_gr)
});
});
break;
case 'en':
$('[lang]').hide();
$('[lang="en"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
break;
};
});
</script>
The External HTML file must have a div section named e.g.
<div id="info_gr" class="info_services" > and/or
<div id="info_en" class="info_services" > or
<div id="bio_history_en" class="biohistory" > and/or
<div id="bio_history_gr" class="biohistory" >
The script goes exactly before the end, specifically exactly before "</html>".
Here it is an actual example, that It uses Language selection, together with loading content using Jquery syntax:
In the body:
<a href="index.html" class="topnav_estatistics">ESTATISTICS </a>
<a id="idStatistics" href ="#Statistics" > <span lang="en">Statistics </span> <span lang="gr">Στατιστική </span> </a>
<a id="idR_Code_PSPP" href ="#R_Code_PSPP" > <span lang="en">R Code / PSPP </span> <span lang="gr"> R Code / PSPP </span> </a>
<a id="idStat_Article" href ="#Stat_Article" > <span lang="en">Stat Articles </span> <span lang="gr"> Άρθρα </span> </a>
<a id="idPlanets_Health" href ="#Planets_Health" > <span lang="en">Planet's Health </span> <span lang="gr"> Περιβάλλον </span> </a>
<a id="idServices" href ="#Services" > <span lang="en">Services </span> <span lang="gr"> Υπηρεσίες </span> </a>
<!--- The Language options --->
<select id="lang_switch" class="lang_switch">
<option value="en">En </option>
<option value="gr">Gr </option>
</select>
The div section where external html pages div-specific content is loaded.
<div id="mainbody" class="main_body"> </div>
<div id="mainbody_2" class="main_body"> </div>
<div id="mainbody_3" class="main_body"> </div>
The language selection together with the Jquery document load of external html div-specific content on specific div section of the current page.
<script>
// stackoverflow: 49637061 & 11134701
$('[lang="en"]').show();
$('[lang="gr"]').hide();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en")
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
$('#lang_switch').change(function () {
var lang = $(this).val();
switch (lang) {
case 'gr':
$('[lang]').hide();
$('[lang="gr"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_gr").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_gr");
$("#left_link_index").load("R_Code_PSPP.html #left_links_gr" )
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_gr").data('url_idStatistics', "Statistics.html#st_gr");
$("#left_link_index").load("Statistics.html #left_links_gr")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_gr" ).data('url_idStat_Article', "Stat_Article.html#st_gr");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_gr").data('url_idPlanets_Health', "Planets_Health.html#st_gr");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_gr").data('url_idServices', "Services.html#st_gr");
$("#left_link_index").load("Services.html #left_links_gr");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_gr', function(){
$("#mainbody").load("Services.html #bio_history_gr").data('url_bio_history_gr', "Services.html#bio_history_gr");
var url_bio_history_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+ $("#mainbody").data('url_bio_history_gr');
$("#mainbody_2").html(url_bio_history_gr)
});
$(document).on('click', '#id_info_gr', function(){
$("#mainbody").load("Services.html #info_gr").data('url_info_gr', "Services.html#info_gr");
var url_info_gr = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_gr');
$("#mainbody_2").html(url_info_gr)
});
});
break;
case 'en':
$('[lang]').hide();
$('[lang="en"]').show();
$(document).ready(function(){
$("#idR_Code_PSPP").click(function(){
$("#mainbody").load("R_Code_PSPP.html #st_en").data('url_idR_Code_PSPP', "R_Code_PSPP.html#st_en");
$("#left_link_index").load("R_Code_PSPP.html #left_links_en")
var url_idR_Code_PSPP = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idR_Code_PSPP');
$("#mainbody_2").html(url_idR_Code_PSPP)
});
$("#idStatistics").click(function(){
$("#mainbody").load("Statistics.html #st_en").data('url_idStatistics', "Statistics.html#st_en");
$("#left_link_index").load("Statistics.html #left_links_en")
var url_idStatistics = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStatistics');
$("#mainbody_2").html(url_idStatistics)
});
$("#idStat_Article").click(function(){
$("#mainbody").load("Stat_Article.html #st_en" ).data('url_idStat_Article', "Stat_Article.html#st_en");
var url_idStat_Article = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idStat_Article');
$("#mainbody_2").html(url_idStat_Article)
});
$("#idPlanets_Health").click(function(){
$("#mainbody").load("Planets_Health.html #st_en").data('url_idPlanets_Health', "Planets_Health.html#st_en");
var url_idPlanets_Health = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idPlanets_Health');
$("#mainbody_2").html(url_idPlanets_Health)
});
$("#idServices").click(function(){
$("#mainbody").load("Services.html #st_en").data('url_idServices', "Services.html#st_en");
$("#left_link_index").load("Services.html #left_links_en");
var url_idServices = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_idServices');
$("#mainbody_2").html(url_idServices)
});
$(document).on('click', '#id_bio_history_en', function(){
$("#mainbody").load("Services.html #bio_history_en").data('url_bio_history_en', "Services.html#bio_history_en");
var url_bio_history_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_bio_history_en');
$("#mainbody_2").html(url_bio_history_en)
});
$(document).on('click', '#id_info_en', function(){
$("#mainbody").load("Services.html #info_en").data('url_info_en', "Services.html#info_en");
var url_info_en = window.location.protocol+"//"+window.location.hostname+":"+ window.location.port+"/"+$("#mainbody").data('url_info_en');
$("#mainbody_2").html(url_info_en)
});
});
break;
};
});
</script>
The External HTML file must have a div section named e.g.
<div id="info_gr" class="info_services" > and/or
<div id="info_en" class="info_services" > or
<div id="bio_history_en" class="biohistory" > and/or
<div id="bio_history_gr" class="biohistory" >
The script goes exactly before the end, specifically exactly before "</html>".
edited Nov 21 '18 at 15:50
answered Nov 21 '18 at 15:45


Elias EstatisticsEUElias EstatisticsEU
134110
134110
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f9256423%2fhow-to-get-the-source-of-the-load-url%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown