Reputation: 914
I have this :
<div id="comments-form-buttons">
<div class="btn" id="comments-form-send"><div><a href="#" tabindex="7" onclick="jcomments.saveComment();return false;" title="Enregistrer (ctrl+entrée)">Enregistrer</a></div></div>
<div class="btn" id="comments-form-cancel" style="display: none;"><div><a href="#" tabindex="8" onclick="return false;" title="Annuler">Annuler</a></div></div>
<div style="clear: both;"></div>
And i would to click on send button. I have try this
submit.Document.GetElementById("jcomments-form-send").InvokeMember("click")
but it doesn't work. Can you help me ? Have a nice day.
Upvotes: 1
Views: 615
Reputation: 90
You can use the CssClass to get the element(div) and access it in the JS! Remember this CssClass should be unique
Upvotes: 2
Reputation: 594
<div id="comments-form-buttons">
<div class="BTN" id="comments-form-send"><div><a href="#BTN" tabindex="7" onclick="jcomments.saveComment();return false;" title="Enregistrer (ctrl+entrée)">Enregistrer</a></div></div>
<div class="btn" id="comments-form-cancel" style="display: none;"><div><a href="#" tabindex="8" onclick="return false;" title="Annuler">Annuler</a></div></div>
<div style="clear: both;"></div>
$(document).ready(function() {
$(".BTN").click(function(e) { // do some thing here });
});
</script>
Upvotes: 1
Reputation: 594
@Oaybi, here in the JS u are using the samething i Said in last answer.
U are using a Class ('myDivClass')
in the JavaScript to get the elemente getElementsByClassName
!
webBrowser1.Navigate("javascript: document.getElementsByClassName('myDivClass')[0].click();void(0);"); //assuming it's first and/or only div with that class
<div id="comments-form-buttons">
<div class="btn" id="comments-form-send"><div><a href="#" tabindex="7" onclick="jcomments.saveComment();return false;" title="Enregistrer(ctrl+entrée)">Enregistrer</a></div></div>
<div class="btn" id="comments-form-cancel" style="display: none;"><div><a href="#" tabindex="8" onclick="return false;" title="Annuler">Annuler</a></div></div>
<div style="clear: both;"></div>
Do that in your code:
CODE: //should be the uniq this class name in this case!! Enregistrer Annuler
JAVA SCRIPT:
webBrowser1.Navigate("javascript: document.getElementsByClassName('_MyDiv_Test1')[0].click();void(0);");
In this case, u get the DIV BY THE CSS CLASS. Just like i said last answer.
try this and tell me if it worked.
Upvotes: 1
Reputation: 914
I have found this
webBrowser1.Navigate("javascript: document.getElementsByClassName('myDivClass')[0].click();void(0);"); //assuming it's first and/or only div with that class
But i don't know javascript, somebody can translate for me please ? My div :
<div id="comments-form-buttons">
<div class="btn" id="comments-form-send"><div><a href="#" tabindex="7" onclick="jcomments.saveComment();return false;" title="Enregistrer(ctrl+entrée)">Enregistrer</a></div></div>
<div class="btn" id="comments-form-cancel" style="display: none;"><div><a href="#" tabindex="8" onclick="return false;" title="Annuler">Annuler</a></div></div>
<div style="clear: both;"></div>
Thank you and have a nice day.
Upvotes: 0