Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 4th, 2006, 10:28 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default Why isn't this working?

Here is my code with some comments:


<SCRIPT LANGUAGE="JavaScript">
var mkdiv = document.createElement('div'); //create your div
var timer //create timer variable
function showItem(posleft, postop, w, h, linkdetail, n)

//posleft = position from the left
//postop = position from the top
//w = pixelwidth
//h = pixelheight
//linkdetail = URL to be shown in the revealed div
//n = text for URL to be shown in the revealed div
//linkno = string built from linkdetail + n to give innerHTML string for divs innerHTML property.


{

linkno ="<a href = " + "\"" + linkdetail + "\"" + ">" + n + "</a>"

    window.clearTimeout(timer)

    mkdiv.style.backgroundColor = "lightblue";
    mkdiv.style.border = "1px solid black";
    mkdiv.style.visibility = "visible"
    mkdiv.style.pixelLeft = posleft
    mkdiv.style.pixelTop = postop
    mkdiv.style.pixelWidth = w
    mkdiv.style.pixelHeight = h
    mkdiv.style.zIndex = 1
    mkdiv.innerHTML = linkno
    //all of this syntax looks fine to me, Im just setting variables using arguments!
    timer = window.setTimeout("hidewin()", 5000)
}

function hidewin(){
mkdiv.style.visibility = "hidden"
}

</SCRIPT>

<a href = "#" onmouseover="showItem(100, 20, 100, 20, this.linkdetail, this.linktext)" linkdetail = "www.google.com" linktext = "Google">Show Link 1</a><br>
<a href = "#" onmouseover="showItem(100, 40, 100, 20, this.linkdetail, this.linktext)" linkdetail = "www.yahoo.com" linktext = "Yahoo">Show Link 2</a>

The script is running without any complaints, but I can't see the div at all! Any ideas? All arguments are passed in on the onmouseover event, such as width and height, position, stuff like that, but I just cannot see the divs as they are 'supposed' to appear.

Help much appreciated.

Joe
__________________
\'sync\' &lt;cr&gt;
The name specified is not recognized as an internal or external command, operable program or batch file.
Reply With Quote
  #2 (permalink)  
Old January 5th, 2006, 11:01 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Joe,

It looks like you are creating the div, but never actually appending it to any element in the page.

Try adding this to your script block...
Code:
window.onload = function(){
    document.body.appendChild( mkdiv );
};
I think you may also want to set style.position = "absolute" for the div

HTH,

Chris



Reply With Quote
  #3 (permalink)  
Old January 6th, 2006, 03:52 AM
Friend of Wrox
 
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Chris,

Thanks for the tip. You were right, I wasn't appending to an element, but instead of using your piece of script I used:

document.body.insertBefore(mkdiv)

You were right on the positioning too. Thanks for the help!

Joe
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener working .... not working alyeng2000 Javascript How-To 5 January 5th, 2007 08:05 AM
Web.Config..Working or Not Working peace95 ASP.NET 1.0 and 1.1 Basics 1 September 18th, 2006 06:53 AM
Local COM working , but not working at Web Serv nagen111 .NET Web Services 3 February 19th, 2005 04:22 AM
Example not working CKucler BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 3 December 8th, 2004 11:26 AM
Get Working Copy... not working Enkiel Classic ASP Basics 0 April 21st, 2004 01:41 PM



All times are GMT -4. The time now is 11:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.