Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
create or move image to x,y
Old 07-28-2009, 01:46 PM create or move image to x,y
Experienced Talker

Posts: 41
Trades: 0
Code:
<script language="JavaScript">
function function1() {
    myX.innerHTML = window.event.x;
    myY.innerHTML = window.event.y; 
} 
function function2() {
var x=myX.innerHTML;
var y=myY.innerHTML;
document.getElementById('answer2').innerHTML = "<img src= xxx.gif img border=0 title=x  style=position:absolute;top:document.write(x)px;left:document.write(y)px; width:50px;height:50px; />";
}
</script>
<div id="myDiv" onmousemove="function1()" onclick="function2()"; style="border:solid; width:5500; height:2500;">
  <img src= "xxx.gif" img border=10 title="x" style="position:absolute;top:30px;left:27px;width:540px;height:540px;" />
when i use document.write(x) and document.write(y) inside of function2 it doesnt give me any values,
it does create the image but at the default location

Last edited by flatrat; 07-29-2009 at 01:52 AM..
flatrat is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-28-2009, 05:38 PM Re: create or move image to x,y
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
You shouldn't try to document.write something into the document once all parsing has finished, in response to an event. To insert content in response to an event, you must either use innerHTML or document.createElement, then insert it into a node. See the sticky titled "Fundamentals of Client-Side JavaScript", and the section "DOM Node Manipulation" for more information about this.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-28-2009, 06:10 PM Re: create or move image to x,y
Experienced Talker

Posts: 41
Trades: 0
Code:
<script language="JavaScript">
function function1() {
    myX.innerHTML = window.event.x;
    myY.innerHTML = window.event.y; 
} 
function function2() {
var x1=myX.innerHTML;
var y1=myY.innerHTML;
var x = document.createElement(x)
var x = document.createTextNode(x)
var y = document.createElement(y)
var y = document.createTextNode(y)
x.nodeValue = x1
y.nodeValue = y1
alert(x.data)
alert(y.data)
how do i place into the topx; leftx part of the image

i assume its with document.getElementById(x.nodeValue) but how do i place this inside the "<image ....
and still know what i mean when i do it

Last edited by flatrat; 07-29-2009 at 08:32 AM..
flatrat is offline
Reply With Quote
View Public Profile
 
Old 07-31-2009, 05:57 AM Re: create or move image to x,y
Experienced Talker

Posts: 41
Trades: 0
last night i woke up three times from a dream where i solved this, to bad my solution didnt exsist
i made it out of something else, seems alot more complecated then i would of assumed, needed extra files attached

Last edited by flatrat; 07-31-2009 at 01:24 PM..
flatrat is offline
Reply With Quote
View Public Profile
 
Old 07-31-2009, 01:30 PM Re: create or move image to x,y
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
window.event only works in IE and Opera. Here's a good tutorial that might help you: http://www.quirksmode.org/js/events_access.html
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to create or move image to x,y
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14672 seconds with 12 queries