java - Wicket: scroll to certain anchor after clicking a link -
i've asked similar question form, need scroll anchor after user clicked link - my solution other thread not work. :(
final link link = new statelesslink("linkid") { @overrride public void onclick() { dosomething(); add(new behavior() { @override public void renderhead(component component, iheaderresponse response) { super.renderhead(component, response); response.render(new headeritem() { @override public iterable<?> getrendertokens() { return collections.singletonlist("javascript-anchor"); } @override public void render(response response) { response.write("<script type=\"text/javascript\">\n"); response.write("window.location.href='#rules';\n"); response.write("</script>\n"); } }); } }); setresponsepage(getclass(), getpageparameters()); } }
what's wrong approach , how achieve desired scrolling-to-anchor effect?
i'm using following non-javascript code instead:
final link link = new statelesslink("linkid") { @overrride public void onclick() { dosomething(); final string url = requestcycle.get().geturlrenderer().renderfullurl(url.parse(urlfor(getclass(), getpageparameters()))) + "#rules; setresponsepage(new redirectpage(url)); } }
Comments
Post a Comment