Link to home
Start Free TrialLog in
Avatar of xenium

asked on

Auto-resize HTML frame depending on window size


I'd like the resize this frame depending on the window size, how can i do this?


<iframe width="1000" height="600" scrolling="no" frameborder="no" src=";viz=GVIZ&amp;t=GRAPH&amp;gc=true&amp;gd=true&amp;sdb=1&amp;rmax=100000&amp;q=select+col0%2C+col2+from+1pNOeGhfGxNU9RvFgGMC5egdSprZL-6q50jt9anr5&amp;qrs=+where+col0+%3E%3D+&amp;qre=+and+col0+%3C%3D+&amp;qe=&amp;uiversion=2&amp;state=%7B%22ps%22%3A%221_0_1w_1_t_3a_1_x_-f_u_5_k_d_w_-c_1_m_13_-u_12_-16_b_16_e_-1i_8_2j_s_9_2o_m_4_1n_y_3_1x_-10_2_10_-c_a_2p_-j_6_20_z_q_1d_-q_b_2l_-p_c_1a_s_d_2a_-x_e_2s_-c_f_1t_11_g_27_z_y_3z_-k_i_1q_-x_j_23_-x_k_2t_-3_l_2d_v_n_2f_-s_o_15_-j_p_11_e_r_1j_-w_s_2r_g_u_1g_w_v_y_-4_13_-15_1f_z_46_9_10_3z_n_11_46_-6_1_z_5_14_-p_1p_15_-1b_z_7_2t_8_17_-e_-1x_h_15_m_%22%2C%22cx%22%3A85.96027096386045%2C%22cy%22%3A8.76855179300828%2C%22sw%22%3A639.789842687397%2C%22sh%22%3A245.5175468552088%2C%22z%22%3A0.999142241431289%7D&amp;gco_forceIFrame=true&amp;gco_hasLabelsColumn=true&amp;width=1000&amp;height=600"></iframe>

Open in new window

Avatar of Sandy Locke
Sandy Locke

Remove the local width and height attributes from the tag and use CSS to specify them.  Then you can use media queries to specify alternate CSS based on the width of the device used for viewing. you could also do the change during load with javascript to test viewport width and either change the specific attributes or swap classes.  If you use javascript you will need to add an id to the iframe tag so you can get a handle on it.
Avatar of xenium


Great thanks, I'm new to javascript, could you link to an example page that does, and mention the main elements, so I can try to copy the code over?
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xenium


Great thanks a lot, that works :-)
You are welcome.