我有一个 javascript 小部件,它通过 MediaWiki API (http://en.wikipedia.org/w/index.php?title=Main_Page&action=render) 从 Wikipedia 获取文章。这是三星智能电视的应用程序。现在文本部分工作正常,但它不会显示任何图像,因为 img src 的结构如下:
“//en.wikipedia.org/wiki/File:example.jpg”
我通过使用 PC 模拟器意识到三星固件将其转换为这种类型的完整 url:
“文件://本地主机/en.wikipedia.org/wiki/文件:example.jpg”
是否可以在 src 中添加“http:”,以便应用程序指向正确的链接,从而同时显示缩略图和全尺寸图像?
这是js代码的相关部分:
UIContents.showImage = function(srcURLFromWikiPage, showHigherResolution) {
// alert("UIContents.fillDescription()");
var cutURL = srcURLFromWikiPage;
//document.getElementById('UIContentsImgFrameiFrame').href = srcURL;
//window.frames.UIContentsImgFrameiFrame.location.href = srcURL + "#file";
//prepare link for full-size picture:
//cutURL = cutURL.replace('thumb/','');
//cutURL = cutURL.substring(0, cutURL.lastIndexOf('/'));
//show preview thumb version
//if (cutURL.match(/\.svg$/)) cutURL = srcURLFromWikiPage;
alert('img src: ' + cutURL);
//show preview thumb version
var elemImg = document.getElementById('UIContentsImgFrameImage');
document.getElementById('UIContentsImgFrame').style.display = 'block';
//set image source
if (showHigherResolution == true) elemImg.onload = 'UIContents.resizeImage()';
elemImg.alt = 'loading...';
elemImg.src = cutURL;
elemImg.style.visibility = 'hidden';
elemImg.style.visibility = 'visible';
imageViewIsOpened = true;
document.getElementById('UISearchField').style.visibility = 'hidden';
document.getElementById('UISearchTextInput').style.visibility = 'hidden';
有什么建议么?提前致谢。