我有一个JS文件,它从HTML页面接受值。我必须使用这个变量在嵌入JS内部的CSS [英] I have a JS file which is accepting value from a HTML page. I have to use this variable inside a CSS embedded inside the JS
问题描述
我使用简单图,这是一个js文件,其中的函数用于从HTML页面获取值。 / p>
JavaScript函数
function getValue(intvalue){
alert(intvalue);
var mapval = intvalue;
}
var simplemaps_worldmap_mapdata = {
main_settings:{
//一般设置
width:1004,
background_color: '#FFFFFF',
background_transparent:'no',
border_color:'#FFFFFF',
zoom:'yes',
pop_ups:'detect',// on_click, on_hover或检测
//国家默认值
state_description:'国家描述',
state_color:'#88A4BC',
state_hover_color:'#3B729F',
state_url:'http://simplemaps.com',
all_states_inactive:'no',
//位置默认值
location_description:'位置描述',
location_color:'#FF0067',
location_opacity:1,
location_url:'http://simplemaps.com',
location_size:35,
location_type:'circle' ,// or circle
all_locations_inactive:'no',
url_new_tab:'no',
initial_zoom:1,
initial_zoom_solo:'no',
auto_load:'yes',
hide_labels:'no'
},
} //结束simplemaps_worldmap_mapdata
我必须动态传递值到'初始缩放',颜色字段。在不同的值,它是不同的级别缩放图像。
我不明白你究竟是什么,但我想你需要访问main_settings对象
您可以通过
访问object中的属性 simplemaps_worldmap_mapdata.main_settings .initial_zoom
和
simplemaps_worldmap_mapdata [main_settings ] [initial_zoom];
I am using simplemaps and this is a js file where a function is used to get values from HTML page.
Javascript function
function getValue(intvalue){
alert(intvalue);
var mapval = intvalue;
}
var simplemaps_worldmap_mapdata = {
main_settings:{
//General settings
width:1004,
background_color: '#FFFFFF',
background_transparent: 'no',
border_color: '#FFFFFF',
zoom: 'yes',
pop_ups: 'detect', //on_click, on_hover, or detect
//Country defaults
state_description: 'Country description',
state_color: '#88A4BC',
state_hover_color: '#3B729F',
state_url: 'http://simplemaps.com',
all_states_inactive: 'no',
//Location defaults
location_description: 'Location description',
location_color: '#FF0067',
location_opacity: 1,
location_url: 'http://simplemaps.com',
location_size: 35,
location_type: 'circle', //or circle
all_locations_inactive: 'no',
url_new_tab: 'no',
initial_zoom: 1,
initial_zoom_solo: 'no',
auto_load: 'yes',
hide_labels: 'no'
},
}//end of simplemaps_worldmap_mapdata
I have to dynamically pass value to the 'initial zoom', colors field. At different value it is zooming the image at different levels.
I dont understand what exactly you asking but I guess you need to access the main_settings object
You can access property in object by
simplemaps_worldmap_mapdata.main_settings.initial_zoom
and
simplemaps_worldmap_mapdata["main_settings"]["initial_zoom"];
这篇关于我有一个JS文件,它从HTML页面接受值。我必须使用这个变量在嵌入JS内部的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!