How to controll size of image? - java
**css File**
#zDIV_slideShow a {color:#fff;background-color:#fff}
#zDIV_slideShow {display:none;position:absolute;left:0;top:0;width:100%;height:100%;background-position:50% 50%;background-repeat:no-repeat;text-align:center;margin:0;z-index:10IE Mac;}
**js File**
var TJK_gallery;
var TJK_anchor;
var TJK_itemNumber;
var TJK_stage;
var TJK_itemTitle;
var TJK_itemDescription;
var TJK_navPrev;
var TJK_navClose;
var TJK_navNext;
var TJK_zCounter;
var TJK_zImage;
function TJK_Gallery(zElement){
TJK_gallery=zElement;
TJK_anchor = document.getElementById(TJK_gallery).getElementsByTagName("a");
// building the whole thing from scratch starting with the slideshow
// zDIV_slideShow
var zDiv_wrapper = document.createElement('div');
document.getElementsByTagName("body")[0].appendChild(zDiv_wrapper);
zDiv_wrapper.id="zDIV_slideShow";
// zA_previous
var zA_1 = document.createElement('a');
var zImg_1 = document.createElement('img');
zDiv_wrapper.appendChild(zA_1);
zA_1.id = "zA_previous";
zA_1.title = "Previous Slide";
zA_1.href = "#null";
zA_1.appendChild(zImg_1);
zImg_1.src="img/previous.gif";
zImg_1.alt="Previous Slide";
// zA_close
var zA_2 = document.createElement('a');
var zImg_2 = document.createElement('img');
zDiv_wrapper.appendChild(zA_2);
zA_2.id = "zA_close";
zA_2.title = "Back to the Gallery";
zA_2.href = "#null";
zA_2.appendChild(zImg_2);
zImg_2.src="img/close.gif";
zImg_2.alt="Back to the Gallery";
// zA_next
var zA_3 = document.createElement('a');
var zImg_3 = document.createElement('img');
zDiv_wrapper.appendChild(zA_3);
zA_3.id = "zA_next";
zA_3.title = "Next Slide";
zA_3.href = "#null";
zA_3.appendChild(zImg_3);
zImg_3.src="img/next.gif";
zImg_3.alt="Next Slide";
// zA_title
var zA_4 = document.createElement('a');
zDiv_wrapper.appendChild(zA_4);
var zTitle = document.createTextNode("Title");
zA_4.id = "zA_title";
zA_4.appendChild(zTitle);
// zDIV_counter
var zDiv_counter = document.createElement('div');
var TJK_zCounter = document.createTextNode("Keeping track");
zDiv_wrapper.appendChild(zDiv_counter);
zDiv_counter.id="zDIV_counter";
zDiv_counter.appendChild(TJK_zCounter);
// zA_image
var zA_6 = document.createElement('a');
var zImg_6 = document.createElement('img');
zDiv_wrapper.appendChild(zA_6);
zA_6.id = "zA_image";
zA_6.appendChild(zImg_6);
zImg_6.id="zIMG";
// zA_description
var zA_5 = document.createElement('a');
var zDescription = document.createTextNode("Description");
zDiv_wrapper.appendChild(zA_5);
zA_5.id = "zA_description";
zA_5.href = "#";
zA_5.appendChild(zDescription);
for (var x=0,i=TJK_anchor.length;x<i;x++){
TJK_anchor[x].onclick = badabingbadaboum;
// we create fragment identifier to be used to navigate and keep track of the items and we kick start the whole thing
TJK_anchor[x].href = TJK_anchor[x].href+"#"+x;
// we create a container to receive the text links
var zSPAN = document.createElement('span');
TJK_anchor[x].appendChild(zSPAN);
var zTextLink = document.createTextNode(TJK_anchor[x].title);
zSPAN.appendChild(zTextLink);
}
}
function goPrevious() {
TJK_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
// hiding the button if we are on first slide
if(TJK_itemNumber==1)this.className="transparent";
TJK_navNext.className="nonOpaque";
if(TJK_itemNumber==0){return} // we are at the beginning
TJK_zImage.src = TJK_anchor[TJK_itemNumber-1].href;
TJK_zImage.alt = TJK_itemTitle.firstChild.data;
TJK_itemTitle.href = TJK_anchor[TJK_itemNumber-1].href;
TJK_itemTitle.firstChild.data = TJK_anchor[TJK_itemNumber-1].getElementsByTagName("img")[0].alt;
TJK_itemDescription.firstChild.data = TJK_anchor[TJK_itemNumber-1].title;
// special care for this one in case there is no long description set
if(TJK_anchor[TJK_itemNumber-1].getElementsByTagName("img")[0].longDesc){
TJK_itemDescription.href = TJK_anchor[TJK_itemNumber-1].getElementsByTagName("img")[0].longDesc;
// appendData() breaks IE5 Win
TJK_itemDescription.firstChild.data=TJK_anchor[TJK_itemNumber-1].title+" [more info...]";
TJK_itemDescription.title = "Follow this link for more Information";
TJK_itemDescription.className="noHand";
TJK_itemDescription.style.textDecoration ="underline";
}else{
TJK_itemDescription.className="withHand";
TJK_itemDescription.title="";
TJK_itemDescription.href="#";
TJK_itemDescription.style.textDecoration ="none";
}
// we update the value of the counter in the DIV
var current = eval(document.getElementById("zA_title").hash.substring(1)) + 1;
TJK_zCounter.firstChild.data = "Item #"+current+" out of "+TJK_anchor.length;
}
function goNext() {
TJK_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
// hiding the button if we are on the last slide
if(TJK_itemNumber==TJK_anchor.length-2)this.className="transparent";
TJK_navPrev.className="nonOpaque";
if(TJK_anchor.length == TJK_itemNumber+1){return} // we are at the end
TJK_zImage.src = TJK_anchor[TJK_itemNumber+1].href;
TJK_zImage.alt = TJK_itemTitle.firstChild.data;
TJK_itemTitle.href = TJK_anchor[TJK_itemNumber+1].href;
TJK_itemTitle.firstChild.data = TJK_anchor[TJK_itemNumber+1].getElementsByTagName("img")[0].alt;
TJK_itemDescription.firstChild.data = TJK_anchor[TJK_itemNumber+1].title;
// special care for this one in case there is no long description set
if(TJK_anchor[TJK_itemNumber+1].getElementsByTagName("img")[0].longDesc){
TJK_itemDescription.href = TJK_anchor[TJK_itemNumber+1].getElementsByTagName("img")[0].longDesc;
// appendData() breaks IE5 Win
TJK_itemDescription.firstChild.nodeValue=TJK_anchor[TJK_itemNumber+1].title+" [more info...]";
TJK_itemDescription.title = "Follow this link for more Information";
TJK_itemDescription.className
="noHand";
TJK_itemDescription.style.textDecoration ="underline";
}else{
TJK_itemDescription.className
="noHand";
TJK_itemDescription.title="";
TJK_itemDescription.href="#";
TJK_itemDescription.style.textDecoration ="none";
}
// we update the value of the counter in the DIV
var current = eval(document.getElementById("zA_title").hash.substring(1)) + 1;
TJK_zCounter.firstChild.data = "Item #"+current+" out of "+TJK_anchor.length;
}
// to make sure users don't follow the link in the title (it is there to be used as a match with the thumbnail that triggered the popup DIV)
function fakeIt() {return false}
// hiding the SlideShow
function hideTJK_stage() {
document.getElementById("zDIV_slideShow").style.height="0"; // IE5 Mac
document.getElementById("zDIV_slideShow").style.overflow="hidden"; // IE5 Mac
document.getElementById("zDIV_slideShow").style.display="none";
// we remove the opacity stuff
document.getElementById("wrapper").className="none";
// we set focus back to the thumbnail that triggered the "popup" DIV
var TJK_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
TJK_anchor[TJK_itemNumber].focus();
}
function badabingbadaboum() {
TJK_stage = document.getElementById("zDIV_slideShow");
TJK_itemTitle = document.getElementById("zA_title");
TJK_itemDescription = document.getElementById("zA_description");
TJK_navPrev = document.getElementById("zA_previous");
TJK_navClose = document.getElementById("zA_close");
TJK_navNext = document.getElementById("zA_next");
TJK_zCounter = document.getElementById("zDIV_counter");
TJK_zImage = document.getElementById("zA_image").getElementsByTagName("img")[0];
// we do some opacity stuff
document.getElementById("wrapper").className="transparent";
// IE5 Mac (phantom links)
// this.blur();
// this is to reset the fix for IE Mac (see statement in (hideTJK_stage())
TJK_stage.style.height="20%";
TJK_stage.style.display="block";
TJK_zImage.src = this.href.replace(this.hash,"");
TJK_zImage.alt = this.getElementsByTagName("img")[0].alt;
TJK_zImage.onclick = hideTJK_stage;
// "style.cursor" breaks IE5
TJK_zImage.className = "hand";
TJK_zImage.title = "Back to the Gallery";
// the href value we set for this anchor will be used to give focus back to the appropriate thumbnail
TJK_itemTitle.setAttribute("href",this.href);
// since we have a real href value in there we don't want the user to trigger the link
TJK_itemTitle.onclick=fakeIt;
// clicking on the close box will close the popup DIV
TJK_navClose.onclick=hideTJK_stage;
// setting the action for the prev/next links
TJK_navPrev.onclick=goPrevious;
TJK_navNext.onclick=goNext;
// now we can set focus for keyboard users
TJK_navPrev.focus();
// setting the height - mainly for IE - the second one is for IE5
TJK_stage.style.height = (document.documentElement.clientHeight > 0) ? document.documentElement.clientHeight+"px" : document.body.clientHeight+"px";
// setting the width for IE 5 so there is no gap near the scrollbar
if(document.documentElement.clientHeight == 0)TJK_stage.style.width=document.body.clientWidth+"px" ;
// setting the title and description
TJK_itemTitle.firstChild.data = this.getElementsByTagName("img")[0].alt;
TJK_itemDescription.firstChild.data = this.title;
// if there is a long description in there, we use it as href value of the short description and we give it a title to. If there is none we make sure we reset values previously set and we do not let the user follow the "empty" link
if(this.getElementsByTagName("img")[0].longDesc){
TJK_itemDescription.href = this.getElementsByTagName("img")[0].longDesc;
// appendData() breaks IE5 Win
TJK_itemDescription.firstChild.data=this.title+" [more info...]";
TJK_itemDescription.title = "Follow this link for more Information";
}else{
TJK_itemDescription.removeAttribute("href");
TJK_itemDescription.title = "";
}
// we set the starting values for the "counter"
var current = eval(TJK_itemTitle.hash.substring(1)) + 1;
TJK_zCounter.firstChild.nodeValue = "Slide #"+current+" out of "+TJK_anchor.length;
// hiding the button when everything "loads" depending on which slide we are on
// first we reset both buttons in case they have been turned off last time the user left the slideshow
TJK_navNext.className="nonOpaque";
TJK_navPrev.className="nonOpaque";
TJK_itemNumber = eval(document.getElementById("zA_title").hash.substring(1));
if(TJK_itemNumber==0){
TJK_navPrev.className="transparent";
TJK_navNext.className="nonOpaque";
}
if(TJK_itemNumber==document.getElementById(TJK_gallery).getElementsByTagName("a").length-1){
TJK_navNext.className="transparent";
TJK_navPrev.className="nonOpaque";
}
return false;
}
**in jsp**
<ul id="gallery" >
<li><a name="zGallery" href="img/NNG.jpg"><img src="img/noida.png" /></a></li>
<li><img src="img/gurgaon.png" /></li>
<li><img src="img/bhiwadi.png" /></li>
<li><img src="img/sohna.png" /></li>
<li><img src="img/YamunaExpressway.png" width="260" /></li>
</ul>
i am using a image as a link so when you click new image will open on top of current page.
i want to control the size of image.I have high pixel image so it covers all my page even more. So what change or extra code i need to use to control the size of image.....
This is an example for you that I have a div(width:500, height: 300) will contain the image and the image(1000px x 500px) like this:
<div style="width: 500px; height: 300px;" id="container">
<img src="yourUrl" id="image"/>
</div>
In javascript I'll do like this:
document.getElementById('image').onload = function(){
if(this.naturalWidth > this.naturalHeight){
this.style.Width = document.getElementById('container').style.Width + " !important";
this.style.Height = "auto !important";
}
else{
this.style.Height = document.getElementById('container').style.Height + " !important";
this.style.Width = "auto !important";
}
}
You can specify the height and width of an image based on pixels or percentage.
Eg: <img src="image.jpg" style="width: 50%; height: 50%"/>
Related
How to out while loop when button is disabled?
I used WebDriver sampler and wrote a Selenium Java script- In below script var x = 0 var nextt = WDS.browser.findElement(pkg.By.xpath("//button[contains(#class,'btn btn-sm btn-light border ml-3')]")) var nextisEnb = nextt.isEnabled() while (true) { if (nextisEnb == true) { //if(next.isEnabled()){ ++x //java.lang.Thread.sleep(2000); var wait9 = new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 9000) wait9.until(org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable(pkg.By.xpath("//button[contains(#class,'btn btn-sm btn-light border ml-3')]"))) nextt.click(); WDS.log.info('btn50-clicked ' + x + 'isEnabled=' + nextisEnb) //break if (nextisEnb == false) { break } } } When nextt button is disabled still it not break the loop . it still running in Jmeter. So how we can out for the loop? I also used below code got same problem var next = WDS.browser.findElement(pkg.By.xpath("//button[contains(#class,'btn btn-sm btn-light border ml-3')]")) while (next.isEnabled()) { java.lang.Thread.sleep(2000); var wait9 = new org.openqa.selenium.support.ui.WebDriverWait(WDS.browser, 9000) wait9.until(org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable(pkg.By.xpath("//button[contains(#class,'btn btn-sm btn-light border ml-3')]"))) next.click(); WDS.log.info('btn50-400clicked') } WDS.log.info('btn2clicked') //java.lang.Thread.sleep(3000); if (!next.isEnabled()) { WDS.log.info('Next button disabled') } How is it resolved?
You're always querying the initial state of the "Next" button, you need to "find" it once again to get the "fresh" status after clicking. My expectation is that when you click the "Next" button the DOM gets refreshed and the button has new properties and you have stored its previous state into a global variable. next.click() WDS.log.info('btn50-400clicked') //here the page has refreshed and you need to "find" the button once again next = WDS.browser.findElement(pkg.By.xpath("//button[contains(#class,'btn btn-sm btn-light border ml-3')]")) if (!next().isEnabled() { break } If anything goes wrong you can always take a screenshot like: var screenshot = WDS.browser.getScreenshotAs(pkg.OutputType.FILE) screenshot.renameTo(new java.io.File('screenshot.png')) or print the current HTML source code of the page to JMeter.log file like: WDS.log.info(WDS.browser.getPageSource()) to check the button state either visually or by inspecting its HTML definition. More information: The WebDriver Sampler: Your Top 10 Questions Answered
How do I load a my Java applet on a Click event?
I have a div where I load a Java applet, but the new version of Java is giving an unsigned certificate error: I would like to know if I can restrict the loading of my Java applet (DeployJava.RunApplet), currently instantiated while the page is loaded, to only load when user clicks the View in 3D button? Applet loading code: <div id="appletContainer" runat="server" style="width:(document.body.clientWidth - 270);height:300" clientidmode="Static"> <script type="text/javascript"> var showCI = 0; if (document.getElementById("hdnHas3D").value == "1" && !isAppleMobile()) { var J3DStyleID = document.getElementById("hdn3DStyleID").value; var code = "com.wirefusion.player.AppletPlayer"; var archiveList = "Some achive List"; var width = document.body.clientWidth - 270; var height = 300; var attributes = { id: "appletContainerX", name: J3DStyleID, code: code, codebase: ".", width: width, height: height, mayscript: "true" }; var parameters = { progressFunc: "handleAppletProgress", archive: archiveList, java_arguments: "-Xmx200m", regid: "6050-25", resourcefolder: "/RichContent/3D_Vehicles/J3D/Vehicles/" + J3DStyleID + "/", preloadfile: J3DStyleID + ".jar", environmentType: "WEBSITE", environmentWidth: width, environmentHeight: height, groupsXMLFile: "../../Resources/groups.xml", vehicleXMLFile: J3DStyleID + ".xml" }; var version = '1.6.0_20'; if (deployJava.versionCheck(version + '+')) { docWriteWrapper(function () { deployJava.runApplet(attributes, parameters, version); }); } else { if (document.getElementById("iframeContainer").style.display != "none") { alert("Unable to load Interactive mode"); showCI = 1; } } } </script> </div>
Don't include the regular <applet> (or <object>) tag in your HTML. Instead follow this tutorial on how to do dynamically add it to your page, using JavaScript. HTML 4 function loadApplet(code,codebase,width,height,alt){ var placeholder=document.getElementById('placeholder'); if(window.opera){ placeholder.innerHTML='<applet code="'+code+'" codebase="'+codebase+'" width="'+width+'" height="'+height+'" alt="'+alt+'"></applet>'; }else{ var a=document.createElement('applet'); a.setAttribute('code',code); a.setAttribute('codebase',codebase); a.setAttribute('width',width); a.setAttribute('height',height); a.setAttribute('alt',alt); placeholder.appendChild(a); } } HTML 5 function loadApplet(code,codebase,width,height,alt){ var placeholder=document.getElementById('placeholder'); var a = document.createElement('object'); a.setAttribute('type','application/x-java-applet'); a.setAttribute('width',width); a.setAttribute('height',height); a.setAttribute('alt',alt); var codeParam = document.createElement('param'); codeParam.setAttribute('name','code'); codeParam.setAttribute('value',code); a.appendChild(codeParam); var codebaseParam = document.createElement('param'); codebaseParam.setAttribute('name','codebase'); codebaseParam.setAttribute('value',codebase); a.appendChild(codebaseParam); placeholder.appendChild(a); } In your HTML create a placeholder DIV, i.e. where you want to it to be loaded into, and a link to load your applet. You will need to customise the values in the load link to your values of the Applet. <div id="placeholder"></div> <input type="button" value="Load Applet" onclick="loadApplet('TestApplet.class','.','200','300','demo applet')" /> The linked tutorial explains more about how to make it pretty. The code above is just simply the concept. Update since modification of question Your code appears to load the applet using JavaScript already. The problem is the script is being run as soon as the page is loaded and not when the user clicks on the View in 3D button. To prevent it running immediately, you can wrap the loader code in a function called loadApplet. So explained in pseudo code: function loadApplet() { // Your existing applet loading code } So using your included source code, I have wrapped it with a function, which will prevent it running when your page is loaded. <div id="appletContainer" runat="server" style="width:(document.body.clientWidth - 270);height:300" clientidmode="Static"> <script type="text/javascript"> // Wrap your code with a function called loadApplet function loadApplet() { // Your applet loading code: var showCI = 0; if (document.getElementById("hdnHas3D").value == "1" && !isAppleMobile()) { var J3DStyleID = document.getElementById("hdn3DStyleID").value; var code = "com.wirefusion.player.AppletPlayer"; var archiveList = "Some achive List"; var width = document.body.clientWidth - 270; var height = 300; var attributes = { id: "appletContainerX", name: J3DStyleID, code: code, codebase: ".", width: width, height: height, mayscript: "true" }; var parameters = { progressFunc: "handleAppletProgress", archive: archiveList, java_arguments: "-Xmx200m", regid: "6050-25", resourcefolder: "/RichContent/3D_Vehicles/J3D/Vehicles/" + J3DStyleID + "/", preloadfile: J3DStyleID + ".jar", environmentType: "WEBSITE", environmentWidth: width, environmentHeight: height, groupsXMLFile: "../../Resources/groups.xml", vehicleXMLFile: J3DStyleID + ".xml" }; var version = '1.6.0_20'; if (deployJava.versionCheck(version + '+')) { docWriteWrapper(function () { deployJava.runApplet(attributes, parameters, version); }); } else { if (document.getElementById("iframeContainer").style.display != "none") { alert("Unable to load Interactive mode"); showCI = 1; } } } } </script> </div> Then to your View in 3D element you must add an onclick attribute calling the loadApplet() function. For example: <input type="button" value="Show in 3D" onclick="loadApplet()" /> Note: It may be the case that your View in 3D button already has an onclick attribute wired to a function that brings your applet into view, in which case you would still want this to be called after your load function. I have used showApplet() as an example, this is most likely different for you. <input type="button" value="Show in 3D" onclick="loadApplet(); showApplet();" /> If you provide the code for your Show in 3D button, I can better assist you here.
Adding google.maps.latlng within a loop
I am new to Java Script. I am using it, in combination with Java Server Faces 2.0. I want to add some points to define a Polilyne using GoogleMaps Apiv3. My problem is that I can't add a FOR statement to the javascript, because it dumps. If I comment this FOR loop, it also dumps. The dump I am getting is: "javax.servlet.ServletException: null source". Has anyone any suggestion to solve this? Thanks in advance, Emanuel <script type="text/javascript"> function initialize() { var longit = "${dateRange.longitude}" ; var lat = "${dateRange.latitude}" ; var latlng = new google.maps.LatLng(lat, longit); var myOptions = { zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var points = []; var cadena1 = "${dateRange.latArray}" ; var cadena2 = "${dateRange.longArray}" ; var latArray = cadena1.split('?'); var longArray = cadena2.split('?'); /* The code Below is the one that fails */ for (var i=0; i < latArray.length; i++) { points.push(new google.maps.LatLng(latArray[i], longArray[i])); } /* Finish of the error code */ // The Polilyne is created var mapPath = new google.maps.Polyline ({ path: points, strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 4 }); mapPath.setMap(map); } </script> </head> <body onload="initialize()"> <h:graphicImage url="http://localhost:8080/gps_tracking/faces/resources/images/logo.jpg"> </h:graphicImage> <h1 align="center">Sol-Tech</h1><br /> <hr></hr> <div id="map_canvas" style="width:100%; height:100%"></div> </body>
How to clik on a text in the div
Could any one please help me in selecting the text (en_GW) under a div? <-div class="x-combo-list-inner" id="cq-gen339" style="width: 253px; height: 300px;"> <-div class="x-combo-list-item x-combo-selected" ext:qtip="">en_GW<-/div><-div> Note: Below code not working: driver.findElement(By.className("x-combo-list-item x-combo-selected")).click(); Error Compound class names are not supported. Consider searching for one class name and filtering the results.
// xpath driver.findElement(By.xpath("//div[contains(#class, 'x-combo-list-item x-combo-selected')]")).click(); // css selector driver.findElement(By.cssSelector("div.x-combo-list-item.x-combo-selected")).click();
$.fn.clickToggle = function(func1, func2) { var funcs = [func1, func2]; this.data('toggleclicked', 0); this.click(function() { var data = $(this).data(); var tc = data.toggleclicked; $.proxy(funcs[tc], this)(); data.toggleclicked = (tc + 1) % 2; }); return this; }; $(txt5).clickToggle(function() { alert('First handler: ' + $(this).text()); }, function() { alert('Second handler: ' + $(this).text()); }); i have no of elements if clicking div count will increase. at the same time click other div first will count will be 0 ?
How do I click a javascript button with htmlunit?
I'm working on an application that will automatically click a button on a webpage using htmlunit in Java. Only problem is that that button is a javascript button, so the standard getInputByName() won't work. Any suggestions with dealing with this? The code for the button is included below. <a class="vote_1" id="1537385" href="/javascript%3Avoid%280%29/index"><img src="/images/parts/btn-vote.gif" alt="Btn-vote" /></a> In addition, here's the other code for voting. <div id="content"><script type="text/javascript" src="/js/scriptFeeds/voteArticle.js"></script> Which leads to the following javascript: var pressed = new Array(); $j(document).ready(function() { var nr = $j("input#number_of_articles").val(); for(var i=1; i<=nr; i++){ $j("a.vote_"+i).click(function(){ var article = $j(this).attr("id"); $j('#'+article).hide(); if (!pressed[article]) { pressed[article] = "yes"; jQuery.post('/vote-article', { _token: $j("#_token").val(), article_id: article },function(data) { $j("span.numberOfVotes_"+data.id).html(data.votes); }, "json"); } return false; }); } });
Try using this addOn for firefox, it records your actions and generates the HTMLUnit code for the same. may be it could help. http://code.google.com/p/htmlunitscripter/
There's nothing special about clickable images. Something like this should work: button = page.getHtmlElementById( "1537385" ) ; page = button.click() ; HtmlUnit will then run the Javascript and return the updated page. If the id attribute of the 'a' tag isn't constant, you may need to use XPath to grab it.
I have a very similar link on one of my pages. If you can call .click() on any HtmlElement, it should be able to run associated Javascript. Here is my code (generated from HtmlUnitScripter): HtmlElement element4 = null; Iterable<HtmlElement> iterable5 = page.getAllHtmlChildElements(); Iterator<HtmlElement> i6 = iterable5.iterator(); while(i6.hasNext()) { HtmlElement anElement = i6.next(); if(anElement instanceof HtmlImage) { HtmlImage input = (HtmlImage) anElement; String[] elements = "http://example.com/pages/powerbutton.png".split( "/" ); if(input.getSrcAttribute().indexOf(elements[elements.length-1] )> -1 ) { element4 = input; break; } } } HtmlPage page = element4.click();