假设我有以下代码:
<div id="link_other">
<ul>
<li><a href="http://www.google.com/">google</a></li>
<li>
<div class="some_class">
dsalkfnm sladkfm
<a href="http://www.yahoo.com/">yahoo</a>
</div>
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,JavaScript将添加target="_blank"到div中的所有链接link_other.
我怎么能用JavaScript做到这一点?
我正在使用PhoneGap编写iPad应用程序,我想加载外部URL而不触发Safari或使用像ChildBrowser这样的内部Web浏览器.
我正在使用PhoneGap iPad/iPhone示例项目,我尝试了不同的方法.在onBodyLoad()函数中,我添加了:
window.location.href('http://www.wordreference.com');
Run Code Online (Sandbox Code Playgroud)
但是这一行使用一个新的Safari窗口打开链接.从那时起,无法返回PhoneGap
之后,我尝试使用document.write替换页面内容的AJAX请求
function loadHTML(url, timeout) {
if (timeout == undefined)
timeout = 10000;
var req = new XMLHttpRequest();
var timer = setTimeout(function() {
try {
req.abort();
} catch(e) {}
navigator.notification.loadingStop();
},timeout);
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status < 300) {
clearTimeout(timer);
var html = req.responseText;
//just a debug print
alert(html);
document.write(html);
}
navigator.notification.loadingStop();
delete req;
}
};
req.open('GET', url, true);
req.send();
}
Run Code Online (Sandbox Code Playgroud)
现在,从onBodyLoad()内部调用:
loadHTML('http://www.wordreference.com',10000);
Run Code Online (Sandbox Code Playgroud)
打开PhoneGap容器中的链接,没问题.关键是我想加载用Python编写的动态页面
loadHTML('http://www.mysite.com/cgi-bin/index.py',10000)
Run Code Online (Sandbox Code Playgroud)
此时未调用Safari,但会显示PhoneGap容器中的黑色页面!我想指出,如果我在Safari中键入它,链接就完全正常工作(我无法报告隐私问题).
可能是与某种必要的许可有关的问题???
我找到了与PhoneGap for …
如何知道或检查两个浏览器选项卡是否已打开,如果这些选项卡是打开的,用户将收到一个警告框或消息框,说"网址已经打开",类似于纯/原生JavaScript?此浏览器选项卡包含一个外部网站,我没有任何权限来操纵或更改它.谢谢
示例网址
yahoo.com and google.com
Run Code Online (Sandbox Code Playgroud)
如果已经打开yahoo.com和google.com的标签,我想提醒用户
我想使用tabCreate打开这样的URL:
tabCreate("http://maps.google.com/", "tabMapsPermanentAddress");
mean to open a new tab, it is use in creating chrome extension
Run Code Online (Sandbox Code Playgroud) 我的服务器出了问题.我有四个入站链接到我的动态网页的不同网站,看起来像这样:
myurl.com/default/Site%3Fid%3D13
Run Code Online (Sandbox Code Playgroud)
他们应该是这样的:
myurl.com/default/Site?id=13
Run Code Online (Sandbox Code Playgroud)
我知道那些%3F是?符号的转义序列,而且%3D是等号的转义序列.但是当我使用这些链接时,我确实收到错误400.我该怎么办?
这四个链接适用于不同的网站,我想随着时间的推移会有更多这样的链接.所以对所有人的一个解决方案将是完美的
我想知道在使用外部链接与打开电子表格和复制单元格(使用VBA)时是否有性能提升.
我认为Excel必须打开文件一样,但是当我使用以下代码进行测试时,外部链接会更快地出现:
Dim t As Double
Dim rng As Range
For Each rng In shtId.Range("A1:A5")
t = Now
ThisWorkbook.Names("rngID").RefersToRange = rng
ThisWorkbook.UpdateLink "H:\manualData.xlsx", xlExcelLinks
Debug.Print "link: " & Format(Now - t, "######.0000000")
t = Now
Workbooks.Open "H:\manualData.xlsx", readonly:=True
ActiveWorkbook.Close False
Debug.Print "open: " & Format(Now - t, "######.0000000")
Next
Results:
link: .0000116
open: .0000231
link: .0000116
open: .0000347
link: .0000000
open: .0000347
link: .0000000
open: .0000347
link: .0000000
open: .0000347
Run Code Online (Sandbox Code Playgroud)
该工作簿具有一系列单元格,其中查找公式键入ID字段.这些公式有外部链接.为了测试它,我更改了ID并强制更新.要测试文件打开方法,我只需打开并关闭源文件.
我希望加快由于网络带宽较低而导致问题的进程.我已经探索了各种选项,只想了解这是否有效.我搜索了这个主题,有些人说外部链接可能会导致性能问题,而有些人却说不然.我想更好地了解外部链接背后的机制,以便我能够理解实现时会发生什么.
有什么想法吗?
好的,浏览问题我找到了将外部页面加载到phonegap视图的正确方法(即不丢失会话或打开设备浏览器),如下所述:如何在phonegap webview中加载网页? 在这里:iPhone的PhoneGap:加载外部URL的问题
下一步是:在我打开一个extarnal页面(它由我拥有并且我可以修改它)后,我怎么能回到我的本地应用程序?假设我在外部页面中有一个链接,我希望用户在单击时重定向回到phonegap应用程序内的本地html页面(mypage.html).
链接的href属性应该包含哪些URL?我已经尝试将其设置为"file:///android_asset/www/mypage.html"但是没有用
我需要以与setOpenExternalLinkQlabel 相似的方式(在默认浏览器中)打开某些链接,但需要单击菜单中的某个项目。
有一些简单的方法吗?我考虑使用带有必需链接的Qlabel并使用一些操作/事件来假装单击它,这意味着Qlabel被隐藏了。
我写了这段代码:
// print.h
#pragma once
#ifdef __cplusplus
#include <string>
void print(double);
void print(std::string const&);
extern "C"
#endif
void print();
Run Code Online (Sandbox Code Playgroud)
以及源文件:
// print.cxx
#include "print.h"
#include <iostream>
void print(double x){
std::cout << x << '\n';
}
void print(std::string const& str){
std::cout << str << '\n';
}
void print(){
printf("Hi there from C function!");
}
Run Code Online (Sandbox Code Playgroud)
以及驱动程序:
// main.cxx
#include "print.h"
#include <iostream>
int main(){
print(5);
print("Hi there!");
print();
std::cout << '\n';
}
Run Code Online (Sandbox Code Playgroud)
当我编译时:
gcc -c print.cxx && g++ print.o main.cxx -o prog …Run Code Online (Sandbox Code Playgroud) 我目前正在使用docker-compose设置一系列微服务,这些微服务我想链接到常见的错误记录服务(在compose外部创建)。
我在撰写之外创建errorHandling服务。
docker run -d --name errorHandler
Run Code Online (Sandbox Code Playgroud)
然后我运行撰写(总结):
version: '2'
services:
my-service:
build: ../my-service
external_links:
- errorHandler
Run Code Online (Sandbox Code Playgroud)
我在应用程序中使用主机名别名('errorHandler'),但似乎无法将它们连接起来。我如何检查服务是否在组合网络中被发现?