JAVASCRIPT - HTML Nugget on Page
Posted: Mon Sep 18, 2006 4:01 am
Hello,
I am trying to add a JavaScript image fader to the head using the plugin.
Here are some specs to hopefully get the easy questions out of the way...
- I am clicking "<>" and adding the code.
- Nugget Placement: HEAD tag of the page
- I am selecting "NO" for Performing Markup Transformations
- Item to be displayed: All times
After I hit "Save" and I hit "<>" to look at the code here is what is reads:
<script type="text/javascript"></script><style type="text/css"></style>
Here is the JavaScript that I'm tyring to add:
<script type="text/javascript">
<!--
document.write("<style type='text/css'>.hideimg {visibility:hidden;}</style>");
function initImage() {
i = 1;
while (true) {
imageId = 'theimg' + i;
obj = document.getElementById(imageId);
if (obj == null) break;
setOpacity(imageId, 0);
obj.style.visibility = "visible";
fadeIn(imageId);
i++;
}
}
delay=15;
function fadeIn(objId) {
opacity = 1;
if (document.getElementById) {
while (opacity <= 100) {
window.setTimeout("setOpacity('"+objId+"',"+opacity+")", delay);
opacity += 1;
delay += 10; // modify to change fade speed
}
}
}
function setOpacity(objId, opacity) {
if (document.getElementById) {
obj = document.getElementById(objId);
opacity = (opacity == 100)?99.999:opacity;
// IE/Win
obj.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2 Konqueror
obj.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
obj.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
obj.style.opacity = opacity/100;
}
}
window.onload = function() {initImage()}
// -->
</script>
I'm not sure if this is a bug, or if it's user error.
If anyone knows a better way to perform image fade-ins when the page loads, please help a brother out.
Thanks in Advance,
Ted
I am trying to add a JavaScript image fader to the head using the plugin.
Here are some specs to hopefully get the easy questions out of the way...
- I am clicking "<>" and adding the code.
- Nugget Placement: HEAD tag of the page
- I am selecting "NO" for Performing Markup Transformations
- Item to be displayed: All times
After I hit "Save" and I hit "<>" to look at the code here is what is reads:
<script type="text/javascript"></script><style type="text/css"></style>
Here is the JavaScript that I'm tyring to add:
<script type="text/javascript">
<!--
document.write("<style type='text/css'>.hideimg {visibility:hidden;}</style>");
function initImage() {
i = 1;
while (true) {
imageId = 'theimg' + i;
obj = document.getElementById(imageId);
if (obj == null) break;
setOpacity(imageId, 0);
obj.style.visibility = "visible";
fadeIn(imageId);
i++;
}
}
delay=15;
function fadeIn(objId) {
opacity = 1;
if (document.getElementById) {
while (opacity <= 100) {
window.setTimeout("setOpacity('"+objId+"',"+opacity+")", delay);
opacity += 1;
delay += 10; // modify to change fade speed
}
}
}
function setOpacity(objId, opacity) {
if (document.getElementById) {
obj = document.getElementById(objId);
opacity = (opacity == 100)?99.999:opacity;
// IE/Win
obj.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2 Konqueror
obj.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
obj.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
obj.style.opacity = opacity/100;
}
}
window.onload = function() {initImage()}
// -->
</script>
I'm not sure if this is a bug, or if it's user error.
If anyone knows a better way to perform image fade-ins when the page loads, please help a brother out.
Thanks in Advance,
Ted