ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Problems with HTML & Javascript.

(1/1)

RedPillow:
So, I have tried to use this ondblclick-function on this string:


--- Code: HTML ---<div style="position: absolute; left: 30px; top: 100px; width: 24px; height: 24px; z-index: 76; cursor: move;" id="Icon"><img height="35" width="35" src="Icon/user_black.png" name="Ico1"/></div>
I need to add javascript ondblclick-function to that string, and the doubleclick must open a window to another html-site on my pc.
The reason I need to put that function there is, because of this:

--- Code: Javascript ---<script type="text/javascript">                 SET_DHTML("Ico1", "Ico2", "Ico3", "Ico4", "Ico5", "Ico6");         </script>
that set_dhtml - thing says where it puts one of my scripts i have in one folder (the script allows visitor of the site to move and resize pictures).
And currently, there reads "Ico1", and that Ico1 is located on that Div-string.

So, where should i stuff that ondblclick-function, and what is the code to open another html-site located on same folder?





housetier:
I suggest you look at jquery.

There are other very very good javascript frameworks out there. I believe Prototype is one suche framework; but there are more.

Pick one and study it, they have all sorts of neat functions that also will work in many browsers.

I have only used jquery myself, hence I recommend it firs.

RedPillow:
but the problem is, that where should i put javascript-fuction ondblclick in this code:

   1.
      <div style="position: absolute; left: 30px; top: 100px; width: 24px; height: 24px; z-index: 76; cursor: move;" id="Icon"><img height="35" width="35" src="Icon/user_black.png" name="Ico1"/></div>

Carol Haynes:
See http://www.w3schools.com/jsref/jsref_ondblclick.asp

I would guess stick the code you want in a function definition and then call it in the div tag

to open a webpage from the double click use window.open() see http://www.w3schools.com/HTMLDOM/met_win_open.asp

Ampa:
It is now considered bad practice to embed javascript event triggers into the html directly. Far better to attach them dynamically once the page has been served.

See this javascript event tutorial which shows how to do this using mootools framework (though most other frameworks will have similar funtionality).

Similarly - I'd suggest that you separate the css style information from the HTML and load it from an external file. This makes code far more understandable, and brings performance advantages too.

Navigation

[0] Message Index

Go to full version