< >

Links-im-neuen-Fenster-oeffnen-oder-im-selben.php


Quell Code


<!DOCTYPE html>
<html lang="de">
<head>
<title>Fenster im neuen Tab oeffnen mit Cookie zum speichern</title>
<style>
body{
width:100%;
}
*{
margin:0;
padding:0;
}
#cookieinfo{
display:flex;
flex-direction:column;
width:100vw;
}
.line{
    display:flex;
    width:100vw;
    
}
span{
    border:1px solid black;
    display:flex;
    flex:1;
 word-break: break-all;
    
}
span:nth-child(1),
span:nth-child(3)
{
flex:1;
}
span:nth-child(2),
span:nth-child(4)
{
flex:5;
}
</style>
</head>
<body>
<script>
function linkopener(a) {
   var b=a?"_blank":"_self";
   var c=document.links;
   for(var i=0;i<c.length;i++) {
       if(c[i].href.search("sebastian1012.bplaced.net")==-1) {c[i].target=b;}
   }
}
if(document.cookie.indexOf('externoeffnen') !== -1){
   addEvent(window, 'load', linkopener);
   document.write ('<form action=""><p class="linkopener"><input type="checkbox" checked="checked" onchange="linkcookie()" onclick="linkopener(this.checked)" id="linksnewwin" /> <label for="linksnewwin">Fremde Seiten in neuem Fenster öffnen?<\/label><\/p><\/form>');
} else {
   document.write ('<form action=""><p class="linkopener"><input type="checkbox" onchange="linkcookie()" onclick="linkopener(this.checked)" id="linksnewwin" /> <label for="linksnewwin">Fremde Seiten in neuem Fenster öffnen?<\/label><\/p><\/form>');
}
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
   obj.addEventListener(evType, fn, false);
   return true;
 } else if (obj.attachEvent){
   var r = obj.attachEvent("on"+evType, fn);
   return r;
 } else {
   return false;
 }
}
</script>
<a href="http://goggle.de">Google</a>
<br>
<a href="http://sebastian1012.bplaced.net/">Eigene Seite</a>
<br>
<br>
<h3>Infos über diesen gesetzten coopkie</h3>
<div id="cookieinfo1"></div>
<button id="zeige">Zeige alle Cookies von sebastian1012.bplaced.net</button>
<div id="cookieinfo"></div>
<script>
document.getElementById('zeige').addEventListener('click',function(){
     allecookie(1)
});
co=document.getElementById('cookieinfo');
co1=document.getElementById('cookieinfo1');
gesetzte=document.cookie;
function allecookie(g){
var cookieList = (document.cookie) ? document.cookie.split(';') : [];
var sammeln='';
var cookieValues = {};
for (var i = 0, n = cookieList.length; i != n; ++i) {
  var cookie = cookieList[i];
  var f = cookie.indexOf('=');
  if (f >= 0) {
    var cookieName = cookie.substring(0, f);
    var cookieValue = cookie.substring(f + 1);
    console.log(g)
    if(g==1){
        sammeln+="<div class='line'><span width='200px'>cookieName</span><span width='200px'>" + cookieName + "</span><span> cookieValue  </span><span>" + cookieValue+"</span></div><br>";
    }else if(g==0){
          if(cookieName==' extern'){
           co1.innerHTML="cookieName = " + cookieName + "<br> cookieValue  =" + cookieValue;
          }
    }
    if (!cookieValues.hasOwnProperty(cookieName)) {
      cookieValues[cookieName] = cookieValue;
    }
  }
}
 if(g==1){
 co.innerHTML=sammeln;
 }
if(co1.innerHTML==''){
co1.innerHTML= 'Dieses Script hat noch kein Cookie gesetzrt';
}

}

function linkcookie() {
  if(document.cookie.indexOf('externoeffnen') !== -1){
      document.cookie = 'extern=0;path=/; expires=Thu, 31 Dec 2099 23:59:59 UTC';
  } else {
      document.cookie='extern=externoeffnen; path =/; expires=Thu, 31 Dec 2099 23:59:59 UTC';
  }
  allecookie(0)
}
allecookie(0)

</script>
</body>
</head>

Add Comment

* Required information
1000
Powered by Commentics

Comments (1)

Gravatar
Admin
Sascha65says...

Die Canvas Balken Uhr ist ja mal Fett