Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by noble · Jan 01, 2012 at 12:31 AM · javascriptobject

JavaScript and Ajax second addition Tutorial 11 case problem 2

Having problem with shadow code shadow.js or overlay.js. My shadow appears in front of my box instead of behind it.

Here is the shadow.js

Custom objects and methods

shadow(source, offX, offY, r, g, b, op) Constructs a shadow object for the source object with horizontal and vertical offsets offX and offY, and color value r,g,b and opacity op.

*/ function shadow(source, offX, offY, r, g, b, op) { this.srcObject = source; this.offsetX = offX; this.offsetY = offY; this.color = "rgb(" + r + "," + g + "," + b + ")"; this.opacity = op; }

shadow.prototype.addToPage = function() { this.divElem = document.createElement("div"); document.body.appendChild(this.divEle… this.divElem.id = this.srcObject.id + "DropShadow"; this.divElem.style.backgroundColor = this.color; this.divElem.style.width = getStyle(this.srcObject, "width"); this.divElem.style.height = getStyle(this.srcObject, "height"); setOpacity(this.divElem, this.opacity); this.divElem.style.position = "absolute"; this.divElem.style.display = "none"; var objectZ = getStyle(this.srcObject, "z-index"); if (objectZ == "auto" || objectZ == "undefined") objectZ = 1; this.srcObject.style.zIndex = objectZ + 1; this.divElem.style.zIndex = objectZ;

}

overlay.js

addEvent(window, "load", addOverlay, false);

function addOverlay() {

var allOverlayTargets = document.getElementsByTagName("td");

for (var i = 0; i < allOverlayTargets.length; i++) {

var overlayID = allOverlayTargets[i].id + "Overlay"; var overlay = document.getElementById(overlayID);

allOverlayTargets[i].onmouseover = function(e) { this.style.backgroundColor = "rgb(255, 225, 255)"; } allOverlayTargets[i].onmouseout = function(e) { this.style.backgroundColor = "rgb(255, 255, 255)"; }

allOverlayTargets[i].onmousedown = function(e) { var evt = e || window.event; var overlay = document.getElementById(this.id + "Overlay"); overlay.style.display = "block";

if (evt.pageX) { overlay.style.left = evt.pageX + 5 + "px"; overlay.style.top = evt.pageY + 5 + "px"; } else { var offX = document.documentElement.scrollLeft + document.body.scrollLeft; var offY = document.documentElement.scrollTop + document.body.scrollTop; overlay.style.left = evt.clientX + offX + 5 + "px"; overlay.style.top = evt.clientY + offY + 5 + "px"; } myShadow = new shadow(overlay, 13, 13, 0, 0, 0, 30); myShadow.addToPage(); myShadow.divElem.style.display = "block"; myShadow.divElem.style.left = parseInt(overlay.style.left) + myShadow.offsetX + "px"; myShadow.divElem.style.top = parseInt(overlay.style.top) + myShadow.offsetY + "px"; }

allOverlayTargets[i].onmouseup = function(e) { var evt = e || window.event; var overlay = document.getElementById(this.id+"Overlay… overlay.style.display = "none"; var shadowElem = document.getElementById(overlay.id + "DropShadow"); document.body.removeChild(shadowElem); }

} }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Attach object as child using code 1 Answer

gameObject.active Find 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Setting Scroll View Width GUILayout 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges