Exccute Javascript in IE

Ombir

Active Member
Joined
Oct 1, 2015
Messages
433
Hi,

I want to click on button on a webpage which doesn't contains button tag. I think it is associated with javascript code execution. Below is the Html Code of complete webpage.

HTML:
<!DOCTYPE html>
<html>
<head>
****** http-equiv="Content-Type" content="text/html; charset=utf-8" />
****** name="keywords" content="work, allocation, tool" />
****** name="description" content="Work Allocation Tool" />
****** http-equiv="X-UA-Compatible" content="IE=8" />
<title>Work Allocation Tool</title>
<link rel="stylesheet" href='css/style_agent.css' type="text/css" />
<link rel="stylesheet" href='css/jquery-ui.css' type="text/css"/>

</head>
****** class="login-bdy">

<div class="login-container-index">
  <div class="login-container-inner" id="home_pg_container">
    
      
      <div class="logon-btn"></div>
    </div>
</div>

******** src="js/jquery.js" language="javascript" type="text/javascript">*********>
********>
    $(document).ready(function() {
        $(".logon-btn").click(function() {
            var winWidth = screen.width;
            var winHeight = screen.height - 154;
            ************("Login.htm","_blank","width=" + winWidth + " , height=" + winHeight + ", scrollbars=1, titlebar=1, status=1, menubar=1, top=0, resizable=1, left=0, location=1 ");
            //************("Login.htm","_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=0, left=0, menubar=yes, status=yes, titlebar=yes, fullscreen=yes");
            $(".logon-btn").addClass('ui-disabled').attr("disabled","disabled");
        })                           
    })
*********>
</body>
</html>


I am to able to find any way to click the button of class="logon-btn".

Any help is much appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Have you tried using the .getElementsByClassName() function?

Something like this:
Code:
Public ieApp As InternetExplorer

Sub test()[INDENT]Set ieApp = New InternetExplorer
[/INDENT]
[INDENT]ieApp.Visible = True
ieApp.Navigate "yourURL"

Call busy

Set ieDoc = ieApp.document
ieDoc.getElementsByClassName("logon-btn")(0).Click

'More code[/INDENT]
End Sub

Sub busy()[INDENT]Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop
[/INDENT]
End Sub
 
Upvote 0
Have you tried using the .getElementsByClassName() function?

Something like this:
Code:
Public ieApp As InternetExplorer

Sub test()[INDENT]Set ieApp = New InternetExplorer
[/INDENT]
[INDENT]ieApp.Visible = True
ieApp.Navigate "yourURL"

Call busy

Set ieDoc = ieApp.document
ieDoc.getElementsByClassName("logon-btn")(0).Click

'More code[/INDENT]
End Sub

Sub busy()[INDENT]Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.readyState = READYSTATE_COMPLETE: DoEvents: Loop
[/INDENT]
End Sub

Yeah I tried that approach but no avail. It is giving object error. But now I'm able to click using below code.

Code:
doc.getelementbyid("home_pg_container").Children(0).Click

Regards,
Ombir
 
Upvote 0
Don't click the button, all that button is doing is opening a window to login. You could just navigate directly to that window?
 
Upvote 0
Don't click the button, all that button is doing is opening a window to login. You could just navigate directly to that window?

Hi Kyle,

Although the problem is solved but I would like to know how to navigate to window without clicking on button.

Regards,
Ombir
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top