简体   繁体   中英

Simple html dom get value from javascript

Is it possible to get javascript var by using Simple html dom or are there other options?

    <script type="text/javascript">
        function initialize() {
            var latlng = new google.maps.LatLng(11.80991, 1.98722);
            var myOptions = {
                zoom: 15,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };


include('simple_html_dom.php');
// Retrieve the DOM from a given URL
$html = file_get_html('url');

I want the lat and lng when i parse the url by Simple Html Dom. Is that possible?

I'm not sure what you're looking for. But maybe it's this:

function initialize() {
    var latlng = new google.maps.LatLng(11.80991, 1.98722);
    var lat = latlng.lat();
    document.getElementById('lat').innerHTML = "Latitude: " + lat;
    var lang = latlng.lng();
    document.getElementById('lang').innerHTML = "Longitude: " + lang;

    //Both:
    document.getElementById('both').innerHTML = "Lat/Long: " + latlng;
}
window.onload = initialize();

JsFiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM