Hi there, I just found these forums and several questions I had have been answered by just reading the posts but this one.
I have simplified my code in order to just get to the point with my question.
This is my html code: -
<html>
-
<head>
-
</head>
-
<body>
-
-
<img id="img1" src="images/smile.jpg" style="border:#0000FF solid 2px;"/>
-
-
<script language="javascript">
-
-
my_image = new Image;
-
my_image.src="images/sad.jpg"; my_image.style.border="#FFFFFF solid 5px";
-
-
x=document.getElementById("img1");
-
x=my_image;
-
</script>
-
-
</body>
-
</html>
-
Before I set "x=my_image ", the x object is referring to the image object within the document, so far so good. After the assignment, x is referring to the my_image object and now there is no relationship at all with the image within the document. What I want to accomplish is for the image object within the document to be referring to the my_image object so it updates all of the properties I pre-set for my_image(which will be several in my real code). How can I do that?, or is it best to remove the image object and then append the new my_image to the document(or to the container that will hold it)?
I want to do an image slicing within an html document so I would be updating that object with different images and properties through an adequate set of controls and javascript events of course, this code is just the idea to present my problem.
3 1232
The Image object is not an html element. It does have a src property, which you can read and apply to an img element.
my_image = new Image();
my_image.src="i mages/sad.jpg";
document.getEle mentById("img1" ).src= my_image.src;
rnd me 427
Recognized Expert Contributor
The Image object is not an html element.
dont want to be a wise-guy, but i think you might be wrong: -
var i = new Image(100,100);
-
-
alert(i.constructor) // "HTMLImageElement"
-
-
// also it can be appended just like any other element:
-
-
i.src="http://bytes.com/forum/customavatars/avatar117351_1.gif";
-
document.body.appendChild(i)
-
-
rnd me 427
Recognized Expert Contributor
What I want to accomplish is for the image object within the document to be referring to the my_image object so it updates all of the properties I pre-set for my_image(which will be several in my real code). How can I do that?, or is it best to remove the image object and then append the new my_image to the document(or to the container that will hold it)?
I want to do an image slicing within an html document so I would be updating that object with different images and properties through an adequate set of controls and javascript events of course, this code is just the idea to present my problem.
>> How can I do that?, : you can't. once its in the dom, you have to use dom MPEs to alter it in a way that changes appear.
>> or is it best to remove the image object and then append the new my_image to the document(or to the container that will hold it)? : thats what i would do, or perhaps give the tag a id, and put all of your images inside the container, img.style.displ ay="none".
then simply 1. hide all of them. 2. show the one you need. to change the image.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
So far I've got the code you see below. I've not yet figured out how
to change the name of the file. I'm creating several images of
different sizes. I need to give them all different names. How do I
control the name?
function makeImage($pathToImage=false, $desiredSize=false) {
|
by: Wayne's World |
last post by:
hi everyone,
i have a big problem, writing a image from my applet to my apache
webserver. i tried three way's of writing that file. every way was
described in forums to solve this problem, but non of them worked and
i don't know why. i'll give you the code of my writing-methods and
describe, what happen when i test them, in order someone of you can
give me a usefull tip, where the problem is.
as inputparameter i give my method a new...
|
by: D. Alvarado |
last post by:
Hello,
I am trying to open a window containing an image and I would like
the image to be flush against the window -- i.e. have no padding or
border. Can I make this happen with a single call to a window.open
function? I would prefer not to create a separate HTML page. So far
all I have is the basic
var cwin = window.open('images/KJV-THANKS.gif',
'Thanks', 'width=243,height=420,');
cwin.focus();
|
by: Anand Ganesh |
last post by:
HI All,
I have an Image. I want to clip a portion of it and copy to another image.
How to do this? I know the bounding rectangle to clip.
Any suggestions please.
Thanks for your time and help.
Regards
|
by: lgbjr |
last post by:
Hello All,
I¡¯m using a context menu associated with some pictureboxes to provide
copy/paste functionality. Copying the image to the clipboard was easy. But
pasting an image from the clipboard is proving to be more difficult. These
pictureboxes are bound to an AccessDB. If the user wants to add an image,
they select an image using an OpenFileDialog:
Dim result As DialogResult = Pic_Sel.ShowDialog()
If (result = DialogResult.OK) Then
| |
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you experts.
I would like to produce Javascript classes that can be "subclassed"
with certain behaviors defined at subclass time. There are plenty of
ways to do this through prototyping and other techniques, but these
behaviors need to be static and...
|
by: Michael Moreno |
last post by:
Hello,
In a class I have this code:
public object Obj;
If Obj is a COM object I would like to call in the Dispose() method the
following code:
System.Runtime.InteropServices.Marshal.ReleaseComObject(Obj);
|
by: Martin Clark |
last post by:
Hello, I am daring to stick my head above the parapet and ask as
question. I am working on redesigning a website to use CSS rather than
tables for layout. I have come across a problem when trying to float an
image to the right.
For ease of looking at the problem, I have stripped away other parts of
the page layout, and have just included the "content" section in the
examples below.
The basic design of having a left column and a main...
|
by: kombu67 |
last post by:
I'm reading a series of images from a MS SQL table and saving them to
directory. These are staff ID pictures from our security card app.
Once I've extracted the ID photo from the security app to disk, I need
to reference the disk file in our HR app. As part of the process, I'm
resizing the image and changing its resolution from 96 to 72 dpi. If
they are not at a 72 dpi resolution, the HR app freezes. The resizing
works without a hitch, but...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |