What is the "output" after adding these codes?韋信 wrote:唔得 ..... 我諗諗其他辦法。wmmokk wrote:I have not use BBCode before but I guess you can write code as :韋信 wrote:This is refering to :wmmokk wrote:Where is ""http://on099.com/download/file.php?avat ... 994888.jpg" come from? (is it the url variable?)韋信 wrote:呢個係 view source code 出黎既樣,好似唔係好得wmmokk wrote:Code: Select all
var regexURL = /^(?:(?:www\.)?on099\.com\/download\/)?file\.php\?id=([0-9]+)/i; if (url.test(regexURL)) { // add .jpg } else { // no need to add }
![]()
Code: Select all
<p id="inner"></p> <script type="text/javascript"> var regexURL = /^(?:(?:www\.)?on099\.com\/download\/)?file\.php\?id=([0-9]+)/i; if (url.test(regexURL)) { document.getElementById('inner').innerHTML = "<a class=\"fancybox\" rel=\"fancybox-button\" href=\"http://on099.com/download/file.php?avatar=114_1414994888.jpg.jpg\"><img src=\"http://on099.com/download/file.php?avatar=114_1414994888.jpg\" alt=\"\" /></a>"; } else { document.getElementById('inner').innerHTML = "<a class=\"fancybox\" rel=\"fancybox-button\" href=\"http://on099.com/download/file.php?avatar=114_1414994888.jpg\"><img src=\"http://on099.com/download/file.php?avatar=114_1414994888.jpg\" alt=\"\" /></a>"; } </script>
If the url variable have http:// then the regexURL should beCode: Select all
var regexURL = /^(?:(?:http:\/\/)?(?:www\.)?on099\.com\/download\/)?file\.php\?id=([0-9]+)/i; }
http://www.on099.com/viewtopic.php?p=2544#p2544" onclick="window.open(this.href);return false;
When I apply this code to BBCode setting:
It did not work on your previous post.Code: Select all
<p id="inner"></p> <script type="text/javascript"> var regexURL = /^(?:(?:www\.)?on099\.com\/download\/)?file\.php\?id=([0-9]+)/i; if (url.test(regexURL)) { document.getElementById('inner').innerHTML = "<a class=\"fancybox\" rel=\"fancybox-button\" href=\"{URL}\"><img src=\"{URL}\" alt=\"\" /></a>"; } else { document.getElementById('inner').innerHTML = "<a class=\"fancybox\" rel=\"fancybox-button\" href=\"{URL}.jpg\"><img src=\"{URL}\" alt=\"\" /></a>"; } </script>
Code: Select all
<p id="inner"></p> <script type="text/javascript"> var url = "{URL}"; var regexURL = /^(?:(?:http:\/\/)?(?:www\.)?on099\.com\/download\/)?file\.php\?id=([0-9]+)/i; if (url.test(regexURL)) { document.getElementById('inner').innerHTML = "<a class=\"fancybox\" rel=\"fancybox-button\" href=\"{URL}\"><img src=\"{URL}\" alt=\"\" /></a>"; } else { document.getElementById('inner').innerHTML = "<a class=\"fancybox\" rel=\"fancybox-button\" href=\"{URL}.jpg\"><img src=\"{URL}\" alt=\"\" /></a>"; } </script>
關乎 on099 福祉:求教 javascript 高手
- wmmokk
- Posts: 781
- Joined: Wed Oct 29, 2014 4:04 pm