Menu

Absolute URL for external script/stylesheet

Help
Daniel L.
2008-09-08
2013-04-27
  • Daniel L.

    Daniel L. - 2008-09-08

    Hi,

    I'd like to replace the relative URLs in the following code to absolute:

    ...
    <script language="JavaScript" type="text/javascript" src="foo.js"></script>
    <link href="bar.css" rel="stylesheet" type="text/css" />
    ...

    I've tried LinkTag, ScriptTag and StyleTag without success.

    What is the best way to go about doing this?

    Cheers.

     
    • 贺 博

      贺 博 - 2008-10-14

      Like this, modify the attribute of 'src'.
      ---------------
      String src = scriptTag.getAttribute("src");               
      if(src!=null){
         scriptTag.setAttribute("src",
              modifyUrl(src)
      );
      }
      ---------------

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.