开发者

unresponsive onclick event in OpenLayer.Popup.FramedCloud

I'm using OpenLayer.Popup.FramedCloud from OpenLayer (JavaScript Mapping Library). in the popup constructor there is a parameter called contentHTML. I put there html button with onlick event:

contentHTML = "<button type='button' onclick='alert()'>Hello</button>";

from some reason the button doesn't respond to a click. Why? Is there a solution for this?

Maybe this is because the web page is uploaded in Winform WebBrowser? I noticed that when I upload the page with a regular browser (chrome) everything's working but not in Winform WebBrowser.

the complete popup object:

        var lonlat = new OpenLayers.LonLat(lon, lat);
        var size = new OpenLayers.Size(300,200)
        var htmlString = "<button type='button' onclick='alert()'>Hello</button>";
    popup = new OpenLayers.Popup.FramedCloud("popup", 
                                              lonlat, 
                                              size, 
                                              htmlString,                 
                                              anchor=null,   
                                              closeButtonX =false);      开发者_如何学C   
        popup.id = callId;
        g_waze_map.map.addPopup(popup);

thanks a lot.


Well, I'm developing and using OpenLayers.Popup.FramedCloud and works fine (even with your contentHTML). Here is my code:

// i.e. x = 100, y = 300;

var popup = new OpenLayers.Popup.FramedCloud(
    "getfeature",
    map.getLonLatFromPixel(new OpenLayers.Pixel(x,y)),
    new OpenLayers.Size(300,200),
    "<button type='button' onclick='alert()'>Hello</button>",
    null,
    true
);
popup.autoSize = false;
map.addPopup(popup);

The popup automatically open and shows me the button. When I click on it, an alert is displayed with text 'undefined'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜