简体   繁体   中英

Javascript error when calling a function in initialize()

I have a page for carpools. I made some changes to the function that calls initialize and now getting errors. Here is the page:

http://www.comehike.com/hikes/hike_carpool.php?hike_id=180

What is the correct way to have the second argument when I call the initialize function? I think some JavaScript errors are coming from there.

You're not using your quotes right:

onload="initialize( 180 , "Hike_Carpool" ); placeHikeStartMarker( 180 );  placeCarpoolPassengersMarkers( 180 ); placeCarpoolDriversMarkers( 180 );"

Should be:

onload="initialize( 180 , 'Hike_Carpool' ); placeHikeStartMarker( 180 );  placeCarpoolPassengersMarkers( 180 ); placeCarpoolDriversMarkers( 180 );"

Notice the single-quotes on the Hike_Carpool parameter.

This is because of the double-quoted onload element attribute. The double-quotes on the initialize function cannot be parsed correctly, creating a syntax error.

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