Inactive onclick event in OpenLayer.Popup.FramedCloud

I am using OpenLayer.Popup.FramedCloud from OpenLayer (JavaScript Display Library). there is a contentHTML parameter in the popup constructor. I added an html button with an onlick event there:

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

for some reason, the button does not respond to a click. What for? Is there a solution for this?

Perhaps this is because the webpage is loading in Winform WebBrowser? I noticed that when I load a page with a normal browser (chrome), everything works but not in Winform WebBrowser.

full popup:

        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);         
        popup.id = callId;
        g_waze_map.map.addPopup(popup);

Many thanks.

+3
source share
1 answer

Well, I develop and use OpenLayers.Popup.FramedCloud and works great (even with your HTML content). 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);

. , 'undefined'.

+3

Source: https://habr.com/ru/post/1789547/


All Articles