public
Last active

  • Download Gist
stackoverflow-questions-704758.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>example</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/* uncomment this for the last test*/
/* #example-para{display:none !important; visibility: hidden !important} */
</style>
</head>
<body id="example">
<div id="example-branding">
<h2 id="example-heading"><a href="http://www.example.com">Example Site</a></h2>
<p id="example-para">Example paragraph</p>
</div>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
 
var elem = $("example-para");
var wrapper = $("example-branding");
 
console.log("displayed wrapper, displayed elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
elem.hide();
console.log("displayed wrapper, hidden elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
elem.show();
wrapper.hide();
console.log("hidden wrapper, shown elemm:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
wrapper.show();
elem.setStyle({visibility:"hidden"});
console.log("displayed wrapper, invisible elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
wrapper.setStyle({visibility:"hidden"});
elem.setStyle({visibility:"visible"});
console.log("invisible wrapper, visible elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
wrapper.setStyle({visibility:"visible"});
elem.setStyle({textIndent:"-10000px"});
console.log("visible wrapper, negative indented elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
elem.setStyle({textIndent:"0px"});
wrapper.setStyle({textIndent:"-10000px"});
console.log("negative indented wrapper, visible elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
wrapper.setStyle({textIndent:"0px"});
elem.setStyle({position:"relative",left:"-10000px"})
console.log("visible wrapper, negative positioned elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
elem.setStyle({position:"relative",left:"10000px"})
console.log("visible wrapper, positive positioned elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
elem.setStyle({position:"static",display:"inline"})
console.log("visible wrapper, inline elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility")
);
elem.setStyle({display:"block", visibility:"visible"})
console.log("hidden css with !important, displayed elem:" +
"\nviewportoffset() " + elem.viewportOffset() +
"\nvisible() " + elem.visible() +
"\ngetStyle('display') " + elem.getStyle("display") +
"\ngetStyle('visibility') " + elem.getStyle("visibility") +
"\ngetComputedStyle() \n"
);
console.log(getComputedStyle(elem,null));
</script>
 
<!--
Test results in Firebug console:
 
displayed wrapper, displayed elem:
viewportoffset() 8,69
visible() true
getStyle('display') block
getStyle('visibility') visible
 
displayed wrapper, hidden elem:
viewportoffset() 0,0
visible() false
getStyle('display') none
getStyle('visibility') visible
 
hidden wrapper, shown elemm:
viewportoffset() 0,0
visible() true
getStyle('display') block
getStyle('visibility') visible
 
displayed wrapper, invisible elem:
viewportoffset() 8,69
visible() true
getStyle('display') block
getStyle('visibility') hidden
 
invisible wrapper, visible elem:
viewportoffset() 8,69
visible() true
getStyle('display') block
getStyle('visibility') visible
 
visible wrapper, negative indented elem:
viewportoffset() 8,69
visible() true
getStyle('display') block
getStyle('visibility') visible
 
negative indented wrapper, visible elem:
viewportoffset() 8,69
visible() true
getStyle('display') block
getStyle('visibility') visible
 
visible wrapper, negative positioned elem:
viewportoffset() -9992,69
visible() true
getStyle('display') block
getStyle('visibility') visible
 
visible wrapper, positive positioned elem:
viewportoffset() 10008,69
visible() true
getStyle('display') block
getStyle('visibility') visible
 
visible wrapper, inline elem:
viewportoffset() 8,69
visible() true
getStyle('display') inline
getStyle('visibility') visible
 
//uncomment the style def for this test
 
hidden css with !important, displayed elem:
viewportoffset() 8,69
visible() true
getStyle('display') block
getStyle('visibility') visible
getComputedStyle() ComputedCSSStyleDeclaration position=static display=none visibility=hidden
-->
 
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.