Archief - HTML/JS: Bij location.reload() iframe-adres meegeven?

Het archief is een bevroren moment uit een vorige versie van dit forum, met andere regels en andere bazen. Deze posts weerspiegelen op geen enkele manier onze huidige ideeën, waarden of wereldbeelden en zijn op sommige plaatsen gecensureerd wegens ontoelaatbaar. Veel zijn in een andere tijdsgeest gemaakt, al dan niet ironisch - zoals in het ironische subforum Off-Topic - en zouden op dit moment niet meer gepost (mogen) worden. Toch bieden we dit archief nog graag aan als informatiedatabank en naslagwerk. Lees er hier meer over of start een gesprek met anderen.

Bar-Bar Slinks

Legacy Member
Hey,

ik heb op m'n site een aantal kleurenschema's verwerkt. Als men dus op een kleurtje klikt dan ververst de pagina met een andere css-file.
Nu is het probleem dat als je dit doet dat hij de index.html ververst en hierdoor komt de iframe op zijn oorspronkelijke pagina nl. iframe_main_index.html .

Is er een manier om de iframe-pagina te laden waarop men zich bevindt als men een kleur aantikt?

externe js
Code:
// These are the variables; you can change these if you want
var expDays = 9999;  // How many days to remember the setting
var standardStyle = "4"; // This is the number of your standard style sheet; this will be used when the user did not do anything.
var nameOfCookie = "switchstyle"; // This is the name of the cookie that is used.
var nameOfSite = "css-site/";
// These are the names of your different .css files; use the name exactly as on your Web site
var ScreenCSS_1 = 'color_rood.css';
var ScreenCSS_2 = 'color_oranje.css';
var ScreenCSS_3 = 'color_groen.css';
var ScreenCSS_4 = 'color_blauw.css';
var ScreenCSS_5 = 'color_paars.css';

/***********************************************************************************************

	DO NOT CHANGE ANYTHING UNDER THIS LINE, UNLESS YOU KNOW WHAT YOU ARE DOING

***********************************************************************************************/

// This is the main function that does all the work
function switchStyleOfUser(){
	var fontSize = GetCookie(nameOfCookie);
	if (fontSize == null) {
		fontSize = standardStyle;
	}

	if (fontSize == "1") { document.write('<link rel="stylesheet" type"text/css" href="' + nameOfSite + ScreenCSS_1 + '">'); }
	if (fontSize == "2") { document.write('<link rel="stylesheet" type"text/css" href="' + nameOfSite + ScreenCSS_2 + '">'); }
	if (fontSize == "3") { document.write('<link rel="stylesheet" type"text/css" href="' + nameOfSite + ScreenCSS_3 + '">'); }
	if (fontSize == "4") { document.write('<link rel="stylesheet" type"text/css" href="' + nameOfSite + ScreenCSS_4 + '">'); }
	if (fontSize == "5") { document.write('<link rel="stylesheet" type"text/css" href="' + nameOfSite + ScreenCSS_5 + '">'); }
	var fontSize = "";
	return fontSize;
}

var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

// Function to get the settings of the user
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

// Function to get the settings of the user
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

// Function to remember the settings
function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

// Function to remove the settings
function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

// This function is used when the user gives his selection
function doRefresh(){
	location.reload();
}

// This will call the main function.  Do not remove this, because otherwise this script will do nothing...
document.write(switchStyleOfUser());

index.html
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>HTrance</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="description" content="HTrance's site">
	<meta name="keywords" content="HTrance, Diederik, Depourcq, Diederik Depourcq, d²p, Diederik, Depourcq, info, artwork, Case, Chieftec, Tiberium Wars, C&amp;C, command, conquer">
	<link rel="shortcut icon" href="http://users.telenet.be/HTrance/favicon.ico" type="image/x-icon">
		<script type="text/javascript"> /**Takes care of the dynamic iframe**/
		/***********************************************
		* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
		* Visit DynamicDrive.com for hundreds of original DHTML scripts
		* This notice must stay intact for legal use
		***********************************************/
		//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
		//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
		var iframeids=["myframe"]
		//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
		var iframehide="yes"
		var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
		var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
		function resizeCaller() {
		var dyniframe=new Array()
		for (i=0; i<iframeids.length; i++){
		if (document.getElementById)
		resizeIframe(iframeids[i])
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no"){
		var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
		tempobj.style.display="block"
		}
		}
		}
		
		function resizeIframe(frameid){
		var currentfr=document.getElementById(frameid)
		if (currentfr && !window.opera){
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
			currentfr.height = currentfr.Document.body.scrollHeight;
		if (currentfr.addEventListener)
			currentfr.addEventListener("load", readjustIframe, false)
		else if (currentfr.attachEvent){
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
		}
		}
		
		function readjustIframe(loadevt) {
		var crossevt=(window.event)? event : loadevt
		var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
		if (iframeroot)
		resizeIframe(iframeroot.id);
		}
		
		function loadintoIframe(iframeid, url){
		if (document.getElementById)
		document.getElementById(iframeid).src=url
		}
		
		if (window.addEventListener)
		window.addEventListener("load", resizeCaller, false)
		else if (window.attachEvent)
		window.attachEvent("onload", resizeCaller)
		else
		window.onload=resizeCaller
	</script>
	
	<script type="text/javascript">
		<!--
		var time = 3000;
		var numofitems = 2;
		
		//menu constructor
		function menu(allitems,thisitem,startstate)
		{ 
			callname= "gl"+thisitem;
			divname="subglobal"+thisitem;  
			this.numberofmenuitems = numofitems;
			this.caller = document.getElementById(callname);
			this.thediv = document.getElementById(divname);
			this.thediv.style.visibility = startstate;
		}
						 
		//menu methods
		function ehandler(event,theobj)
		{
			for (var i=1; i<= theobj.numberofmenuitems; i++)
			{
				var shutdiv =eval( "menuitem"+i+".thediv");
				shutdiv.style.visibility="hidden";
				shutdiv.style.height='0';
			}
			theobj.thediv.style.visibility="visible";
			theobj.thediv.style.height='35';
		}
						
		function closesubnav(event)
		{
			if ((event.clientX < 40)||(event.clientX > 220))		/**(event.clientY < 260)||(event.clientY > 350)||**/
			{
				for (var i=1; i<= numofitems; i++)
				{
					var shutdiv =eval('menuitem'+i+'.thediv');
					shutdiv.style.visibility='hidden';
					shutdiv.style.height='0';
				}  
			}
		}
		// -->
	</script>

	
	<script type="text/javascript" src="changeStyle.js"></script>
<!--		 <link rel="stylesheet" href="css-site/color_blauw.css" type="text/css" />-->
</head>

<body class="index" onmousemove="closesubnav(event);">
	<div class="opvulbar">
		<div class="HTsite">		<img class="colorchooser" src="images-site/color1_rood.png" alt="rood" onclick="SetCookie(nameOfCookie, 1, exp); doRefresh();" title="make the site red!" style="position: absolute; border:0px; margin: 0px; right: 195px; top: -10px; padding: 0px;"/>
		<img class="colorchooser" src="images-site/color2_oranje.png" alt="oranje" onclick="SetCookie(nameOfCookie, 2, exp); doRefresh();" title="make the site orange!" style="position: absolute; border:0px; margin: 0px; right: 170px; top: -10px; padding: 0px;"/>
		<img class="colorchooser" src="images-site/color3_groen.png" alt="groen" onclick="SetCookie(nameOfCookie, 3, exp); doRefresh();" title="make the site green!" style="position: absolute; border:0px; margin: 0px; right: 145px; top: -10px; padding: 0px;"/>
		<img class="colorchooser" src="images-site/color4_blauw.png" alt="blauw" onclick="SetCookie(nameOfCookie, 4, exp); doRefresh();" title="make the site blue!" style="position: absolute; border:0px; margin: 0px; right: 119px; top: -10px; padding: 0px;"/>
		<img class="colorchooser" src="images-site/color5_paars.png" alt="paars" onclick="SetCookie(nameOfCookie, 5, exp); doRefresh();" title="make the site purple!" style="position: absolute; border:0px; margin: 0px; right: 89px; top: -10px; padding: 0px;"/>

			<div class="menu">
				<a href="iframe_main_index.html" target="inhoud" title="home" class="link_home"></a>
				<a href="iframe_main_about%20us1.html" target="inhoud" class="link_about" title="about d&sup2;p"></a>
				<a href="iframe_main_artwork.html" target="inhoud" class="link_artwork" title="d&sup2;p artwork"></a>
				<a href="iframe_chieftec_index.html" id="gl1" target="inhoud" class="link_chieftec" title="chieftec case" onmouseover="ehandler(event,menuitem1);"></a>
				<div id="subglobal1" class="artworkMenu">
					<a href="iframe_chieftec_index.html" target="inhoud" title="Day of the beginning">Dag 0</a> | 
					<a href="iframe_chieftec_day1_1.html" target="inhoud" title="Day one">Dag 1</a> | 
					<a href="iframe_chieftec_day2_1.html" target="inhoud" title="Day two">Dag 2</a> | 
					<a href="iframe_chieftec_day3_1.html" target="inhoud" title="Day three">Dag 3</a>
					<br />
					<a href="iframe_chieftec_day4_1.html" target="inhoud" title="Day Four">Dag 4</a> | 
					<a href="iframe_chieftec_dayX_1.html" target="inhoud"  title="Day X">Dag X</a> | 
					<a href="iframe_chieftec_dayY_1.html" target="inhoud" title="Day Y">Dag Y</a> | 
					<a href="iframe_chieftec_dayZ_1.html" target="inhoud" title="Day Z">Dag Z</a>
					<br />
					<a href="iframe_chieftec_future.html" target="inhoud" title="Your future...">...</a> 
				</div>
				<a href="iframe_tibwars_index.html" id="gl2" target="inhoud" class="link_tibwars" title="tiberium wars case" onmouseover="ehandler(event,menuitem2);"></a>
				<div id="subglobal2" class="artworkMenu">
					<a href="iframe_tibwars_index.html" target="inhoud" title="Day 0">Dag 0</a> | 
					<a href="iframe_tibwars_plans_1.html" target="inhoud" title="Try-outs">Modellen</a> | 
					<a href="iframe_tibwars_future.html" target="inhoud" title="You future will be like ...">...</a> 
				</div>
				
				<a href="iframe_main_contact%20us.html" target="inhoud" class="link_contact" title="contact d&sup2;p"></a>
				<a href="iframe_main_privacy%20policy1.html" target="inhoud" class="link_privacy" title="privacy policy"></a>
				<a href="iframe_main_2007HTrance.html" target="inhoud" class="link_copyright" title="copyright by superb HTrance"></a>
			</div><!-- end menu -->
			
			<div class="page">
				<iframe id="myframe" src="iframe_main_index.html" name="inhoud" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:685px; display:none;">
				</iframe>
			</div><!-- end page -->
		</div><!-- end site -->
	</div><!-- end opvulbar-->

	<div class="tail">
	</div>

<script type="text/javascript">
    <!--
      var menuitem1 = new menu(7,1,"hidden");
	  var menuitem2 = new menu(7,2,"hidden");
    // -->
    </script> 

</body>
</html>

HTrance

Legacy Member
Nja was dus een bericht van mij. Broer was nog ingelogd en had 't ni door :/
Het archief is een bevroren moment uit een vorige versie van dit forum, met andere regels en andere bazen. Deze posts weerspiegelen op geen enkele manier onze huidige ideeën, waarden of wereldbeelden en zijn op sommige plaatsen gecensureerd wegens ontoelaatbaar. Veel zijn in een andere tijdsgeest gemaakt, al dan niet ironisch - zoals in het ironische subforum Off-Topic - en zouden op dit moment niet meer gepost (mogen) worden. Toch bieden we dit archief nog graag aan als informatiedatabank en naslagwerk. Lees er hier meer over of start een gesprek met anderen.
Terug
Bovenaan