あちらのスクリプトはそもそもの目的が異なる為、そのまま実行したとしてもご希望の結果は得られないと思います。
(参考・流用できそうな部分が多そうだったので参照先として提示しました)
エラーに関してはgosub・returnの不一致によるものの様ですので
button命令にgosub指定が抜けていないか等、適宜修正して下さい。
で該当ページなのですが、やはりと言いますか多重のiframeに囲われています。
#deffunc extractLinks array p0, array p1, int p2, local a, local b, local c, local d, local e
If(p2){LogMes StrF("<%s>SRC:%s",p0("tagName"),p0("src"))};;;;
If(p2){c=p0("contentWindow") :c=c("document")}else{c=p0("document") :sDim p1,$10000}
d=c("links") :a=0,Int(d("length")),0 :sDim b,$400
If(a.1){*@ :e=d(""+a) :b=""+e("href")+"\n" :If(InStr(p1,,b)<0){p1+=b :a.2++} :DelCom e :a++ :If(a<a.1){Goto *@b}}
DelCom d :ComRes d :c->"getElementsByTagName" "frame" :a=0,Int(d("length"))
If(a.1){*@ :e=d(""+a) :extractLinks e,p1,1 :a.2+=stat :DelCom e :a++ :If(a<a.1){Goto *@b}}
DelCom d :ComRes d :c->"getElementsByTagName" "iframe" :a=0,Int(d("length"))
If(a.1){*@ :e=d(""+a) :extractLinks e,p1,1 :a.2+=stat :DelCom e :a++ :If(a<a.1){Goto *@b}}
DelCom d :DelCom c :If(p2==0){LogMes StrF("[links:%d]",a.2)};;;;;
Return a.2
;hrefはやむを得ず全角
;~~~~
sDim links :extractLinks objIE,links,0
のような感じで取得できるかと甘く考えていたのですが、クロスドメイン規制か何かで正攻法での内部リンク取得は厳しそうです。