topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday April 18, 2024, 3:35 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Problems with HTML & Javascript.  (Read 5737 times)

RedPillow

  • Member
  • Joined in 2008
  • **
  • Posts: 141
  • Pillows.
    • View Profile
    • Read more about this member.
    • Donate to Member
Problems with HTML & Javascript.
« on: July 09, 2009, 02:39 PM »
So, I have tried to use this ondblclick-function on this string:

Code: HTML [Select]
  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>

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 [Select]
  1. <script type="text/javascript">
  2.  
  3.                 SET_DHTML("Ico1", "Ico2", "Ico3", "Ico4", "Ico5", "Ico6");
  4.  
  5.         </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

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 1,321
    • View Profile
    • Donate to Member
Re: Problems with HTML & Javascript.
« Reply #1 on: July 09, 2009, 05:18 PM »
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

  • Member
  • Joined in 2008
  • **
  • Posts: 141
  • Pillows.
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Problems with HTML & Javascript.
« Reply #2 on: July 10, 2009, 04:44 AM »
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

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,066
    • View Profile
    • Donate to Member
Re: Problems with HTML & Javascript.
« Reply #3 on: July 10, 2009, 07:24 AM »
See http://www.w3schools...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...DOM/met_win_open.asp

Ampa

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 592
  • I am cute ;)
    • View Profile
    • MonkeyDash - 2 Player strategy boardgame
    • Donate to Member
Re: Problems with HTML & Javascript.
« Reply #4 on: July 10, 2009, 07:41 AM »
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.