Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8808023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:30:55+00:00 2026-06-14T02:30:55+00:00

Here comes my code: function addAlbum(){ var attr; var parent; var newelement; /*image*/ newelement

  • 0

Here comes my code:

function addAlbum(){
    var attr;
    var parent;
    var newelement;

    /*image*/
    newelement = document.createElement("img");
    newelement.src = "criar_album.png";

    attr = document.createAttribute("id");
    attr.value = "addalbum";
    newelement.setAttributeNode(attr);

    attr = document.createAttribute("usemap");
    attr.value = "#addalbum_map";
    newelement.setAttributeNode(attr);

    parent = document.getElementById("content");
    parent.appendChild(newelement);
    /*-----------------------------------------*/

    /*map*/
    newelement = document.createElement("map");

    attr = document.createAttribute("id");
    attr.value = "album_map";
    newelement.setAttributeNode(attr);

    attr = document.createAttribute("style"); /*this part is failing I guess*/
    attr.value = "cursor:pointer";
    newelement.setAttributeNode(attr);

    attr = document.createAttribute("name");
    attr.value = "addalbum_map";
    newelement.setAttributeNode(attr);

    parent = document.getElementById("addalbum");
    parent.appendChild(newelement);
    /*-----------------------------------------*/

    /*area*/
    newelement = document.createElement("area");

    attr = document.createAttribute("shape");
    attr.value = "rect";
    newelement.setAttributeNode(attr);

    attr = document.createAttribute("coords");
    attr.value = "73, 238, 115, 264";
    newelement.setAttributeNode(attr);

    attr = document.createAttribute("onclick");
    attr.value = "createAlbum()";
    newelement.setAttributeNode(attr);

    attr = document.createAttribute("onmouseover");
    attr.value = "highlightOn(470,320,511,346,2)";
    newelement.setAttributeNode(attr);

    parent = document.getElementById("album_map");
    parent.appendChild(newelement);
    /*-----------------------------------------*/
}

Everything seems to work fine except part of cursor changing whenever I pass it over area element. I have done similar thing with a static image defined in html and it works, so now I’m confused why it doesn’t work for dynamically created map?

P.S.: already defined style for “addalbum” id in CSS but it didn’t helped. Btw, I know, there are ways to do it by a tricky way like defining href but I wanna know what’s the real problem here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:30:57+00:00Added an answer on June 14, 2026 at 2:30 am

    See this answer if you are using chrome or Safari. Cursor not changing to pointer in Usemap/area case

    I will add that your code is too complicated. You dont have to add style, id, shape and so on as attributes (attr.value = "cursor:pointer"; will probably never work at all). The code below works fine, results in a nice 1,1,100,100 map with cursor as pointer. But again works only in browsers like Opera and Firefox, but NOT in Chrome or Safari (WebKit).

    var body=document.getElementsByTagName('body')[0];
    
    var img = document.createElement("IMG");
    img.src='1.gif';
    img.useMap='#album_map';
    
    var map = document.createElement("MAP");
    map.id="album_map";
    map.style.cursor="pointer"; //the right way
    
    var area  = document.createElement("AREA");
    area.shape='rect';
    area.coords="1, 1, 100, 100";
    
    map.appendChild(area);
    body.appendChild(map);
    body.appendChild(img);
    

    adding standard events :

    bind predefined function :

    function imgClick() {
        alert('click');
    }
    
    body=document.getElementsByTagName('body')[0];
    var img = document.createElement("IMG");
    img.src='image.gif';
    img.onclick=imgClick;
    body.appendChild(img);
    

    or by socalled anonymous function :

    img.onclick=function() {
        alert('click');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Something like this: _declspec(align(16)) float dens[4]; //Here the code comes. F32vec4 S_START, Pos, _Vector
I am trying to understand this inline assembly code which comes from _hypercall0 here
I've got this code: $(#element).mousemove(function(e) { if(e.pageX == 255) {alert(here);} }); When I move
Hi i have problem with some things Here is the code function get_char_val(merk) {
here is slider code - function scrollToRight() { if (global_current_elem == 5) {elem =
Here is my code. <?xml version=1.0 encoding=utf-8?> <fx:Script> <![CDATA[ import comps.sampleTextArea; import mx.managers.PopUpManager; protected
I happen to come across a Java code at my work place. Here's the
Here comes a simple question, for all those who know javascript. I made an
As I don't want to hijack another thread here comes my question about mappings.
I'm new at Eclipse and the Android applications making so here comes a very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.