Web/Android/iOS - 内部链接 - 寻找 ideas/solution。
Web/Android/iOS - internal links - looking for ideas/solution.
我先描述一下我们现在有什么:
- CMS - 用药物 (meds) 描述填充数据库。药名如
文本框和 CKEditor 用于 HTML 格式的描述。
- WCF - 将数据库导出到 JSON
- Android app- 药物列表,然后 webview 显示药物描述
采用 HTML 格式。
我们需要找到在药物描述中创建内部 links(即:药物名称)的解决方案,这将导致提到的药物描述页面。
我们目前的方法有什么办法可以实现吗?
即使我找到了如何在 CMS 中创建此功能的方法(可能我会使用散列标签来区分外部和内部 links)我仍然不知道如何在 Android应用
如果将此功能添加到我们当前的设置中存在风险或困难,你们至少可以告诉我应该如何构建以应用此内部 link 功能。
我以前从未这样做过,所以我什至不知道从哪里开始。
感谢您的帮助。
您在 CMS 中的链接是否具有自定义 href 格式 - 类似于 drug://drugid
并且比 android 应用程序(加载描述的网络视图,覆盖 shouldOverrideUrlLoading
)
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("drug://")) {
//this is where the click to that href will be intercepted
//extract the id from url and do whatever you want with it
return true; //disable the webview to load that url
}
return false;
}
});
对于 IOS 设备覆盖 shouldStartLoadWithRequest
:
- (BOOL)WebView:(UIWebView *)myWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if([[request.URL absoluteString] hasPrefix:@"drug://"]) {
//this is where the click to that href will be intercepted
//extract the id from url and do whatever you want with it
return NO; //disable the webview to load that url
}
return YES;
}
我先描述一下我们现在有什么:
- CMS - 用药物 (meds) 描述填充数据库。药名如 文本框和 CKEditor 用于 HTML 格式的描述。
- WCF - 将数据库导出到 JSON
- Android app- 药物列表,然后 webview 显示药物描述 采用 HTML 格式。
我们需要找到在药物描述中创建内部 links(即:药物名称)的解决方案,这将导致提到的药物描述页面。
我们目前的方法有什么办法可以实现吗?
即使我找到了如何在 CMS 中创建此功能的方法(可能我会使用散列标签来区分外部和内部 links)我仍然不知道如何在 Android应用
如果将此功能添加到我们当前的设置中存在风险或困难,你们至少可以告诉我应该如何构建以应用此内部 link 功能。 我以前从未这样做过,所以我什至不知道从哪里开始。 感谢您的帮助。
您在 CMS 中的链接是否具有自定义 href 格式 - 类似于 drug://drugid
并且比 android 应用程序(加载描述的网络视图,覆盖 shouldOverrideUrlLoading
)
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("drug://")) {
//this is where the click to that href will be intercepted
//extract the id from url and do whatever you want with it
return true; //disable the webview to load that url
}
return false;
}
});
对于 IOS 设备覆盖 shouldStartLoadWithRequest
:
- (BOOL)WebView:(UIWebView *)myWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if([[request.URL absoluteString] hasPrefix:@"drug://"]) {
//this is where the click to that href will be intercepted
//extract the id from url and do whatever you want with it
return NO; //disable the webview to load that url
}
return YES;
}