如何把标签放入href =“javascript:void(0);”在cdata中的onclick =“function()”

时间:2013-05-03 13:57:05

标签: xml google-maps kml

我正在尝试将此标记设为href =" javascript:void(0);"的onclick ="()的函数"在xml里面的标签cdata但是没有工作

任何解决方案??

感谢您的帮助

这是我的代码

<Folder>
            <name>
                <![CDATA[Cliente Demo]]>
            </name>
            <Placemark>
                <name>
                    <![CDATA[DBR132 - Geo Para el Link]]>
                </name>
                <Snippet>
                    <![CDATA[27/01/2013 12:35:09 p.m. - Vehiculo Estacionado - (Norte)]]>
                </Snippet>
                <description>
                    <![CDATA[Bogota - Britalia - Cl 163B con Kr 50 Altura:2594, Sat:4, Odom:0, Kmh: 0<div id="prueba"><br> <strong>Envio de comandos</strong><br><a href="javascript:void(0);" onclick="function();">UBICACION</a></div>]]>
            </description>
            <LookAt>
                <longitude>-74.0514</longitude>
                <latitude>4.7459</latitude>
                <range>8000</range>
                <tilt>55</tilt>
                <heading>359</heading>
            </LookAt>
            <styleUrl>#icon04</styleUrl>
            <Point>
                <altitudeMode>relativeToGround</altitudeMode>
                <coordinates>-74.0514,4.7459</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <styleUrl>#Norte1</styleUrl>
            <Point>
                <altitudeMode>relativeToGround</altitudeMode>
                <coordinates>-74.0514,4.7459</coordinates>
            </Point>
        </Placemark>
    </Folder>

1 个答案:

答案 0 :(得分:0)

谷歌地图和谷歌地图API KmlLayer将剥离它。您需要使用第三方解析器(如geoxml3

)加载KML

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_KMLwJavascript.kml#prueba

(如果你点击链接并查看javascript控制台,你会看到它试图运行该功能,但它没有定义)。

2nd example, with working "alert"