标签: broken-links

JavaScript/jQuery检查断开的链接

我开发了一个小的Javascript/jQuery程序来访问内部使用的pdf文件集合.如果文件确实存在,我希望突出显示pdf文件的信息div.

有没有办法以编程方式确定文件的链接是否被破坏?如果是这样,怎么样?

任何指南或建议都是适当的.

javascript jquery broken-links

26
推荐指数
1
解决办法
3万
查看次数

链接没有回到目录?

这可能是一个愚蠢的问题,我自己也有答案,但我想知道我做错了什么.我有一个网站,我们称之为www.mysite.com.在这个网站中,我有一些常见问题解答,但是构建网站的人将FAQ页面保存在名为"FAQs"的网站上的目录下.

例如,FAQ页面位于:

www.mysite.com/pages/en/faqs/faq-page1.html.

记下pages/en/目录.理想情况下,我希望所有页面都保存在其他页面下,www.mysite.com/index.html但我不能改变它.

无论如何,当我在这些FAQ页面中的任何一个时,我尝试链接回来说出主页index.html,导航将不会转到页面.所以,例如,当我在:

www.mysite.com/pages/en/faqs/faq-page1.html

我尝试链接回主页

www.mysite.com/pages/en/index.html(这是保存索引页面的地方)导航将无法正常工作.相反它会尝试去www.mysite.com/pages/en/faqs/index.html.

现在我假设发生这种情况是因为我在"faq"目录中,但是如何在链接时返回根目录?链接的代码很简单<a href="index.html">Home</a>.我当然可以放入完整的链接www.mysite.com/pages/en/index.html,这可以解决这个问题,但还有另一种解决方法吗?对不起这么长的帖子,我可能能够更好地解释这个,但我不能:S

提前致谢.

html broken-links

25
推荐指数
3
解决办法
12万
查看次数

检查链接是否损坏

我试图使用Java在网页中找到所有损坏的链接.这是代码:

   private static boolean isLive(String link){

    HttpURLConnection urlconn = null;
    int res = -1;
    String msg = null;
    try{

        URL url = new URL(link);
        urlconn = (HttpURLConnection)url.openConnection();
        urlconn.setConnectTimeout(10000);
        urlconn.setRequestMethod("GET");
        urlconn.connect();
        String redirlink = urlconn.getHeaderField("Location");
        System.out.println(urlconn.getHeaderFields());
        if(redirlink != null && !url.toExternalForm().equals(redirlink))
            return isLive(redirlink);
        else
            return urlconn.getResponseCode()==HttpURLConnection.HTTP_OK;

    }catch(Exception e){

      System.out.println(e.getMessage());
      return false;

    }finally{

        if(urlconn != null)
            urlconn.disconnect();

    }


}

public static void main(String[] s){

    String link = "http://www.somefakesite.net";
    System.out.println(isLive(link));

}
Run Code Online (Sandbox Code Playgroud)

代码参考http://nscraps.com/Java/146-program-code-broken-link-checker.htm.

此代码为所有网页(包括损坏的网页)提供HTTP 200状态.例如, http://www.somefakesite.net/提供以下标题字段:

{null = [HTTP/1.1 200 OK],Date …

java broken-links

7
推荐指数
1
解决办法
5697
查看次数

Firefox显示破碎的图像

在Firefox中,损坏的图像显示为空白空白.在白色背景上,无法区分无图像和损坏图像.这使得识别破碎图像难以识别并使其不受修正.

如何使破碎的图像像在Internet Explorer中一样产生X?

html firefox image broken-links

6
推荐指数
1
解决办法
2万
查看次数

谷歌的jquery CDN脚本链接是否因为某种原因错过了领先的"https:"?

我没有必要抓住链接一段时间,但是当jquery未定义的错误开始出现时,我注意到CDN脚本链接中的url缺少前导"http:"或"https:".它显然会创建一个断开的链接.我想知道这是故意还是Google的错误.任何见解都会很棒.

例如: <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>

应该??: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js"></script>

https://developers.google.com/speed/libraries/devguide

jquery cdn broken-links

6
推荐指数
1
解决办法
841
查看次数

使用Java查找损坏的链接的Selenium WebDriver中的URL格式错误的异常

我在Selenium脚本中使用此代码来查找损坏的链接.所以这是我编写的代码,但在运行时我遇到了格式错误的异常.

public void countNoOfLinksInHomePage(WebDriver fd) throws IOException{
        List<WebElement> listOfElements=fd.findElements(By.tagName("a"));
        //System.out.println(listOfElements.get(0));
        //log.info("name of links is " +listOfElements);
        int countOfElements=listOfElements.size();
        log.info("Total no of links in Homepage is:: " +countOfElements);

        //for(int i=0;i<countOfElements;i++){

            int responseCode=getResponseCode(listOfElements.get(1).getAttribute("href"));
            log.info("Response code of element at index 1 is:: " + responseCode);

            //break;
        //}
    }

    public static int getResponseCode(String url) throws MalformedURLException, IOException{

        URL u=new URL(url);
        HttpURLConnection huc=(HttpURLConnection)u.openConnection();
        huc.setRequestMethod("GET");
        huc.connect();
        return huc.getResponseCode();
    }
Run Code Online (Sandbox Code Playgroud)

testng跟踪是:

java.net.MalformedURLException:未知协议:javascript

java selenium broken-links selenium-webdriver

5
推荐指数
1
解决办法
1355
查看次数

如何在 Python 中处理它们之间包含空格的链接

我试图从网页中提取链接,然后在我的网络浏览器中打开它们。我的 Python 程序能够成功提取链接,但某些链接之间有空格,无法使用request module.

例如,example.com/A, B C它不会使用请求模块打开。但是如果我把它转换成example.com/A,%20B%20C它就会打开。python中有一种简单的方法来填充空格%20吗?

`http://example.com/A, B C` ---> `http://example.com/A,%20B%20C`
Run Code Online (Sandbox Code Playgroud)

我想将它们之间有空格的所有链接转换为上述格式。

python url request broken-links

4
推荐指数
1
解决办法
1922
查看次数

Riak:如果目标被删除,链接是否已解散?

从商店中删除某个项目时,链接会自动从链接到现在缺少的项目的所有文档中删除吗?或者我们的情况类似于HTML页面上的断开链接?

broken-links nosql riak

2
推荐指数
1
解决办法
213
查看次数

这两个HTML锚点有什么区别?

我尝试使用链接检查器查找任何损坏的链接,但第二个没有包含,displayedPage.html显示404错误,但它不会显示在链接检查器的报告中.两者有什么区别<a></a>?为什么第二个被检查为链接?

<a href="showpage.go?page=mypage&room=yours">
<span>my own room</span>
</a>
Run Code Online (Sandbox Code Playgroud)

第二:

<a onclick="javascript:window.open('my/displayedPage.html', '', 
 'width=590,height=450,scrollbars=no,resizable=no'); return true;"
 href="javascript:void(0)">Show Me</a>
Run Code Online (Sandbox Code Playgroud)

html javascript anchor hyperlink broken-links

1
推荐指数
1
解决办法
725
查看次数