.= 'tag.htm'; break; case 'flag': $pre .= $default_pre .= 'flag.htm'; break; case 'my': $pre .= $default_pre .= 'my.htm'; break; case 'my_password': $pre .= $default_pre .= 'my_password.htm'; break; case 'my_bind': $pre .= $default_pre .= 'my_bind.htm'; break; case 'my_avatar': $pre .= $default_pre .= 'my_avatar.htm'; break; case 'home_article': $pre .= $default_pre .= 'home_article.htm'; break; case 'home_comment': $pre .= $default_pre .= 'home_comment.htm'; break; case 'user': $pre .= $default_pre .= 'user.htm'; break; case 'user_login': $pre .= $default_pre .= 'user_login.htm'; break; case 'user_create': $pre .= $default_pre .= 'user_create.htm'; break; case 'user_resetpw': $pre .= $default_pre .= 'user_resetpw.htm'; break; case 'user_resetpw_complete': $pre .= $default_pre .= 'user_resetpw_complete.htm'; break; case 'user_comment': $pre .= $default_pre .= 'user_comment.htm'; break; case 'single_page': $pre .= $default_pre .= 'single_page.htm'; break; case 'search': $pre .= $default_pre .= 'search.htm'; break; case 'operate_sticky': $pre .= $default_pre .= 'operate_sticky.htm'; break; case 'operate_close': $pre .= $default_pre .= 'operate_close.htm'; break; case 'operate_delete': $pre .= $default_pre .= 'operate_delete.htm'; break; case 'operate_move': $pre .= $default_pre .= 'operate_move.htm'; break; case '404': $pre .= $default_pre .= '404.htm'; break; case 'read_404': $pre .= $default_pre .= 'read_404.htm'; break; case 'list_404': $pre .= $default_pre .= 'list_404.htm'; break; default: $pre .= $default_pre .= theme_mode_pre(); break; } if ($config['theme']) { $conffile = APP_PATH . 'view/template/' . $config['theme'] . '/conf.json'; $json = is_file($conffile) ? xn_json_decode(file_get_contents($conffile)) : array(); } !empty($json['installed']) and $path_file = APP_PATH . 'view/template/' . $config['theme'] . '/htm/' . ($id ? $id . '_' : '') . $pre; (empty($path_file) || !is_file($path_file)) and $path_file = APP_PATH . 'view/template/' . $config['theme'] . '/htm/' . $pre; if (!empty($config['theme_child']) && is_array($config['theme_child'])) { foreach ($config['theme_child'] as $theme) { if (empty($theme) || is_array($theme)) continue; $path_file = APP_PATH . 'view/template/' . $theme . '/htm/' . ($id ? $id . '_' : '') . $pre; !is_file($path_file) and $path_file = APP_PATH . 'view/template/' . $theme . '/htm/' . $pre; } } !is_file($path_file) and $path_file = APP_PATH . ($dir ? 'plugin/' . $dir . '/view/htm/' : 'view/htm/') . $default_pre; return $path_file; } function theme_mode_pre($type = 0) { global $config; $mode = $config['setting']['website_mode']; $pre = ''; if (1 == $mode) { $pre .= 2 == $type ? 'portal_category.htm' : 'portal.htm'; } elseif (2 == $mode) { $pre .= 2 == $type ? 'flat_category.htm' : 'flat.htm'; } else { $pre .= 2 == $type ? 'index_category.htm' : 'index.htm'; } return $pre; } ?>javascript - How to open Google Maps links in a pop up window? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to open Google Maps links in a pop up window? - Stack Overflow

programmeradmin0浏览0评论

I'm developing a mobile web app with jQuery+Phonegap which uses the Google Maps API v3 and I'm having some issues with the links attached to the map.

My question is if it's possible to open the Terms and Conditions and the Google Maps links on a pop-up window instead of opening them on the same window to avoid stucking on devices which have no physical buttons like the Apple ones. I've tried to attach an 'click' event to the child elements of the map canvas and to change the target of them but I haven't been able to achive that. Is there a solution?

Thanks.

I'm developing a mobile web app with jQuery+Phonegap which uses the Google Maps API v3 and I'm having some issues with the links attached to the map.

My question is if it's possible to open the Terms and Conditions and the Google Maps links on a pop-up window instead of opening them on the same window to avoid stucking on devices which have no physical buttons like the Apple ones. I've tried to attach an 'click' event to the child elements of the map canvas and to change the target of them but I haven't been able to achive that. Is there a solution?

Thanks.

Share Improve this question edited Jun 21, 2013 at 9:29 alvarofd asked Jun 21, 2013 at 7:21 alvarofdalvarofd 511 silver badge6 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 3

Both of those links have target="_blank" on them, so normally they should open in a new window automatically. For example the Google Maps link looks like this:

<a target="_blank"
   href="http://maps.google./maps?..."
   title="Click to see this area on Google Maps"
   style="position: static; overflow: visible; float: none; display: inline;"
>
    <div ...>
        <img ...>
    </div>
</a>

But it looks like PhoneGap is overriding that behavior as you mentioned in the ment. In fact if you search for:

phonegap target _blank

you will find quite a bit on the topic, in particular this discussion and this issue.

It looks like they want people to use PhoneGap's InAppBrowser, but it appears to be tied specifically into the window.open() function. So you could try changing the href in these <a> elements to use a window.open() call instead of a simple URL.

For example, if you've gotten a reference to one of those <a> elements in a variable called link, you might try:

link.href =
    "javascript:window.open( '" +
        link.href +
     "', '_blank', 'location=yes' );";

That changes the href from:

http://google./etc.etc.

to (actually all on one line, formatted here for readability):

javascript:window.open(
    'http://google./etc.etc.',
    '_blank',
    'location=yes'
);

Another possibility might be the technique in this answer using rel="external" on the <a> tag and a change in the MainViewController. But that is deprecated and requires a similar amount of fiddling with the DOM elements.

One other thought... Normally, fiddling around with the inner workings of these maps and ToS links might be considered a violation of the terms of service. However, I think you could easily argue here that you are merely preserving the original intent of these links in the face of a PhoneGap issue that prevents them from working properly.

Try this in your window.location that you open in new tab :

i.e: <a href="#" onclick="window.open('stackoverflow.')">New Map(In new window)</a>

Try using the ChildBrowser plugin. You still might need to do some JavaScript trickery in order to capture the tap and open it in the ChildBrowser.

Try InAppBrowswer provided by PhoneGap.

http://docs.phonegap./en/edge/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser

SOLVED! I've found a solution on this answer: https://stackoverflow./a/16575541/2507996 . It changes link behaviour capturing the click event and opening new windows with PhoneGap/Cordova InAppBrowser. Thanks all for your answers.

发布评论

评论列表(0)

  1. 暂无评论