VB.net Geckofx 45 executing jquery.hide() has no effect - javascript

I tried the following articles about executing javascript.
But the if-else statement seems not obtaining the capability of jquery.
Dim jQuery As JQueryExecutor
jQuery = New JQueryExecutor(GeckoWebBrowser1.Window)
If (jQuery.ExecuteJQuery("typeof jQuery == 'undefined'").ToBoolean) Then
MsgBox("no jquery here")
else
jQuery.ExecuteJQuery("$(#" + aName + ").hide();")
end if
Is that something i forgotten?
The error is this one

I'm not entirely sure if this is what is triggering the error, but it looks as if your jQuery syntax is faulty; you are selecting by an ID, which jQuery takes as a string parameter, but your .ExecuteJQuery() line does not include the # as a string.
jQuery.ExecuteJQuery(jQuery.ExecuteJQuery("$('#" + aName + "').hide();")
I know quotes can get a bit confusing, and perhaps this might be the issue?

Related

How do I get document.getElementsByTagName('').innerHTML to make text between 2 tags?

I'm trying to use JavaScript to include a footer on several webpages, so if I want to change the footer, I only have to change it in one place. PHP is not available on this server and neither are server side inserts (SSI), but Perl, Python, and Tcl are available. I have been trying with document.getElementsByTagName('footer').innerHTML = "text"; but it doesn't produce text. I copied this code from dev.mozilla, and it tells me how many tags I have:
var footer = document.getElementsByTagName('footer');
var num = footer.length;
console.log('There is ' + num + ' footer in this document');
So, I don't know what's wrong with the innerHTML script. I also tried with paragraph tags and got the same results in both cases.
I reccoment using textContent instead. Se why here.
To see how it works, paste the following into your browser console while you're on StackOverflow and hit enter.
document.querySelector('.site-footer').textContent = 'Custom footer content.'
note: use querySelector with a class instead of getElementByTagName
Cheers! 🍻
Before asking this question, I had searched for Python includes without any luck, so I stopped there, but after asking this question, I thought that I should search for Perl/Ruby includes. Today, I found out that I can use the Perl use function, so I could study that and try to implement it although I am completely new to Perl. Ruby also appears capable, perhaps even more. I have no experience with Ruby either, but maybe I should start there.
I just figured out that getElementsByTagName() results in an array, so I have to refer to the footer's index with [0]:
var footerTags = document.getElementsByTagName('footer');
footerTags[0].innerHTML = "test";

HTML Different styles

Can anyone tell me what is the difference between the two styles of html code written below.
return '<div id='suggestionId' class="autocomplete-suggestion">No Message Found</div>';
Vs
var autoCompleteSuggestion;
autoCompleteSuggestion = $('<div/>').attr({id: 'suggestionId'}).addClass('suggestion').html('No Message Found');
return autoCompleteSuggestion;
Results are same, the below mentioned script what kind of scripting is it called. Would like to know more
The first one is hard-coded vanilla javascript. The second one uses the jQuery api to build the string.
Also, your first one uses quotes incorrectly. But it looks like that's not intentional.
First of all your first script wont work because you use
return '<div id='suggestionId' class="autocomplete-suggestion">No Message Found</div>'; //you should use id="suggestionId".
The first code is a javascript code returns a string which contains tags and attributes of a div.
the second code is written in JQuery and returns a string built by JQuery functions.
The result (if there is no syntax error) will be the same.
Neither one of them is just straight HTML.
The first one is vanilla javascript. But should be written like this
return '<div id=' + suggestionId + ' class="autocomplete-suggestion">No Message Found</div>';
Otherwise suggestionId will throw an error and not render the id.
The second one is written using jQuery, but can be modified to be just
return $('<div/>').attr({id: 'suggestionId'}).addClass('suggestion').html('No Message Found');
Both will render the same to the browser.

Adding JavaScript Function with arguments to an element from code behind

Hi Guys I've been dealing with an estrange thing while trying to pass string parameters to a JavaScript function from code behind, this is what I have actually in code behind which is wrong:
thumbnail = "<a href = 'javascript:RemovePirctureDetail(" + field1 + ",'" + tempname + "');' class='label label-default' rel='tooltip'>Remove</a>";
So this is the bad result I'm getting in the browser:
Remove
Meas that for some reason when I try to pass the string parameter, the html comes out bad formatted. The result should looks like this:
Remove
I tried already send the quotation marks like this /' from code behind, it did not work neither. How can I achieve this?
Thanks.
string thumbnail = "Remove";`
You need to use \ to escape the quotes inside, not /..
With javascript attribute I wouldn't use single quote, because it could be messy
Try to change in this way:
thumbnail = "Remove";
PS: Actually, I would NEVER use single quotes with attributes, it will cause an HTML validation error, HTML is not well formed with single quotes for attributes (although with inspection tools you see double quotes.. because inspection tools have the need to work with a well formed HTML, so if you want to see the real HTML of your page, view the source code (generally the option is on right-click on the page)

Jquery, 'invalid or unexpected token'. Not a string issue

I'm a newbie to javascript and jquery, and this bug has been hounding me for almost a day. Here's the code:
$('#txtTabContentsHeight', '#ddlTabContentsHeightRuler').blur(function ()
{
//need to check ruler val first!
var sruler = $('#ddlTabContentsHeightRuler').children("option").filter(":selected").text‌​().toLowerCase();
var sval = $('#txtTabContentsHeight').val(); + '' + sruler;
ChangeTabContentsCss(this, 'height');
});
I get a jquery error in my browser console on the $('#ddl...').^^children(... line. Even if I do a $('#ddlTabContentsHeightRuler').val(), I get the same error on the '.' of invalid or unexpected token.
I've checked every single similar discussion here and on the web for this kind of error, and it's always about a string issue, or a syntax issue. But for the life of me, I can't see a syntax problem here. The ddl element is a select element, obviously.
Can someone smack me upside the head with an answer?
Try changing .text() for .val() or .html(). The .text() method cannot be used on form inputs
did u need the semi-colon on $('#txtTabContentsHeight').val(); + '' + sruler;or
$('#txtTabContentsHeight').val() + '' + sruler;
Well, as usual when I have these kinds of errors, if I just RETYPED the whole line, the bug disappeared! I actually did an undo, and tried to delete every single character on the original line, to see if I had some 'hidden characters' or something...and NOPE. Still got the error, though the line looked EXACTLY the same as the one that works.
Is this usual with jquery/javascript? That's sort of unacceptable as a programmer...
As earlier suggested, you could use with cross checking your html code especially the id names of the elements being selected

Jquery taconite selector with character that needs to be escaped

I'm using the jquery taconite plugin to make an ajax request that will replace a certain element in my page, however the element has an id like "email.subject"..
I can select it just fine if I do '$("email\\.subject")', but when I try to use the taconite plugin like this:
<taconite>
<replaceWith select="#email\\.subject">
JUCA
</replaceWith>
</taconite>
The plugin log says:
[taconite] No matching targets for selector: #email\\.subject
How can I make this work?
Ok this is what i did. It is not working for me though. (I did not go through the entire source). But it will point you in the right direction.
The problem really is that in the jquery.taconite.js file, around line 152 (if you are looking at the latest version!) you can see:
var q = cmdNode.getAttribute('select');
var jq = $(q);
if i add an alert to the above statement to find out the value of jq it says: [Object object]. But this works as long as it contains no .
The problem is that the author of taconite is not checking for . from the "select" attributes value. The following code works for me when i tried it isolated in a simple js file. But when i use the same in the jquery.taconite.js file it does not work. Needs more tweaking around?
var x = cmdNode.getAttribute('select');
alert(x); //Shows what you have entered in <replaceWith select="#email.subject"> i.e "#email.subject"
var q = x.replace(/\./g, "\\\\\."); //Searches for a . in the string and escapes it! So now it becomes: "#email\\.subject"
alert(q) //Alerts #email\\.subject ... Great! Works fine till this point!
var jq = $(q);
alert(jq[0]); //Says "undefined"!!!! This is where i got stuck! Why does it say undefined??

Categories

Resources