href=“tel:” # symbol in number is not shown - javascript

I want this number "*3*123#" to be inserted as the tel number.
but upon clicking link from android devices the # sign omitted and the number to be dialed is *3*123.I have also tried all of these codes but none of them could do the job.
<a href="tel:*3*123#">
<a href="tel:*3*123&num;">

try this code
<a href="tel:*3*123%23" >Call us!</a>

You can achieve this without JS, by using'&#35', which is the equivalent to &amp => & for the # symbol.
I.e:
tel:*3*123#

Related

UTF-8 decoding help needed

I would like the change the layout of a web application but it is UTF-8 encoded. I have managed to use some online decoders and I know which part to modify but the decoding doesn't seem fully complete to work.
I want to move the div tag marked with * inside the previous one so instead of two lines I can have the data on one line which gives more on screen space.
<li class='ipsDataItem chat_row {{#callme}}ipsDataItem_new{{/callme}}' id='{{id}}'>
<div class='ipsPad_half {{#memberPhoto}}ipsPhotoPanel ipsPhotoPanel_tiny{{/memberPhoto}} ipsClearfix'>
{{#memberPhoto}}
<a href='{{memberUrl}}' class='ipsUserPhoto ipsUserPhoto_tiny' id='ips_uid_{{memberID}}'>
<img src='{{memberPhoto}}' alt=''>
</a>
{{/memberPhoto}}
<div>
<a href='#' data-action='mention' data-member='{{memberName}}'>{{{memberNameFormat}}}</a>
<span class='ipsPos_right'>
<span class='ipsType_small ipsType_light'>{{time}}</span>
{{#canEdit}}<a href='#' data-action='editMSGButton' data-id='{{id}}'><i class='fa fa-pencil-square'></i></a>{{/canEdit}}
{{#canDelete}}<a href='#' data-action='remove' data-id='{{id}}'><i class='fa fa-minus-square'></i></a>{{/canDelete}}
</span>
* <div class='ipsList_inline' id='chatraw_{{id}}' data-id='{{id}}' {{#canEdit}}data-action='editMSG'{{/canEdit}}>{{{message}}}</div>
</div>
</div>
</li>
This is the original encoded xml: https://pastebin.com/papiW75B
and this is what I managed to decode: https://pastebin.com/q24UfAEn. As you can see, the beginning part (line 1) is still a total mess but from line 2 forward it's all good.
What am I missing here? Should I do the decoding in another way?
I wouldn't describe that as being "UTF-8 encoded". It looks to me like obfuscated Javascript. It looks to me as if it's been deliberately obfuscated in order to prevent you doing what you are trying to do -- which I would describe more as reverse engineering rather than decoding. (Indeed, what you are trying to do might well be technically illegal unless you have permission from the copyright owner).
You've already done quite a good job at defeating the intentions of the people who created this application, and I don't think I can help you do any better.

Regex cutting down a specific character

I have this HTML tag <a href="abc> google </a>, how can i put the " after the letter c using regular expression
HTML: <a href="abc> google </a>
Regex: /\=\s*["“'”](.*?)[^“"'”]\s*\>/g
Replace: ="$1">
https://regex101.com/r/1FQods/1
https://jsfiddle.net/liev04/6n038nvm/
How about
str.replace(/href="[^\s>"]+/, function(match) { return match+'"' });
I suggest the following:
str.replace(/=\s*["']([^"']*?)\s*?(?=>)/g,'="\1"');
This should work also in cases where the second " exists already. It also allows for blanks between the = and the beginning of the string.
See here for a demo: https://regex101.com/r/xo52ka/1
Another issue might be cases like:
<a href="abc def > google </a>
My Solution will turn that into
google
But, of course, this solution has its limitations and is by far not watertight. It will only work on the last attribute of each tag (because of the lookahead (?=>) in the regexp).

JavaScript Function Parameter - Syntax Error

This code is working fine. But, I just want to remove variable url in third line and write direct www.google.com. Need corrected syntax of below code please. Quotes are so messy! I know there is just a little mistake. But didn't figure out.
website: function() {
var url = 'www.google.com';
this.echo('<a onclick="openHTTP(\''+url+'\')" href=""> My Website </a>', {raw:true});
You'll want to only replace the delimiting quotations (those ending and starting string literals) as well as +url+.
this.echo('<a onclick="openHTTP(\'www.google.com\')" href=""> My Website </a>', {raw:true});
Noting that your current snippet concatenates 2 literals with the variable:
'<a onclick="openHTTP(\''
'\')" href=""> My Website </a>'
The escaped quotations should be kept for the client-side code. They'll allow the browser to understand www.google.com as a string literal. The \ will be removed by the parser, so the output includes:
<a onclick="openHTTP('www.google.com')" href="">
website: function() {
this.echo('<a onclick="openHTTP(\'http://www.google.com\')" href=""> My Website </a>', {raw:true})
}
please try this one
just replace "url" variable with "www.google.com"
this.echo('<a onclick="openHTTP('www.google.com')" href=""> My Website </a>', {raw:true});

can't use angular value within quotes

Why does this not work:
<ul class="dropdown-menu">
<li ng-repeat="choice in dropDownItems">
<a class="btn" ng-click="mnuClick('{{choice}}')">{{choice}}</a>
</li>
</ul>
But this does work:
<ul class="dropdown-menu">
<li ng-repeat="choice in dropDownItems">
<a class="btn" ng-click="mnuClick('xxx')">{{choice}}</a>
</li>
</ul>
In the top example, the mnuClick() routine never gets called, but in the bottom example, it does. When I do an 'inspect element' everything looks fine.
It does not work, because the way you did it you are saying that you want to provide the string {{choice}} to the mnuClick function.
When providing xxx, this is actually correct, hence you need the quotes here.
But when using {{choice}}, you don't want THAT string, but you want that expression to be evaluated and its result (which is probably a string) as a parameter - hence you don't need the quotes (and not even the curly braces) here.
So just write
<a class="btn" ng-click="mnuClick(choice)">{{choice}}</a>
and you're fine :-).
To cut it short: In one case you deal with an expression which resolves to a string, in the other case you deal with a string directly. Hence one time you don't need quotes, the other time you do.
If you want more detailed information on when to use curly braces and when not, check out this answer to this question: Difference between double and single curly brace in angular JS?
Hope this helps.
PS: Inside the text of your a tag, you need the double curly-braces, as you're not in a AngularJS controlled code-block here - hence you have to mark it as binding, otherwise it'd just be text inside of HTML.
The value of ng-click is interpreted as an angular expression so you don't have to use the curly brackets around "choice". Just write it like this:
<a class="btn" ng-click="mnuClick(choice)">{{choice}}</a>
Doesn't this work?
ng-click="mnuClick(choice)"
I've definitely done something along those lines plenty of times, but don't have code to hand to verify...

Javascript regexp issue - matches only part of result

I'm using this regex
<a [^>]*href[ ]*=[ ]*\"|'[^>]\"|'[^>]*>
to search in example string:
idhasidhioashdoihas <a onclick=alert('blablabla') href='www.hello.com'
onclick=alert('blablabla') > asdfsgdufisdugfusdg
It should match
<a onclick=alert('blablabla') href='www.hello.com'onclick=alert('blablabla') >
but it only matches
'blablabla') href='www.hello.com' onclick=alert('blablabla') >
Any idea where is the problem?
Your | is in the wrong place:
<a [^>]*href[ ]*=[ ]*\"|'[^>]\"|'[^>]*> is effectively:
<a [^>]*href[ ]*=[ ]*\" or '[^>]\" or '[^>]*>
If you want to mark " or ' in this exact place use []:
<a [^>]*href\s*=\s*["'][^>]*["'][^>]*>
Example:
a = "idhasidhioashdoihas <a onclick=alert('blablabla') href='www.hello.com' onclick=alert('blablabla') > asdfsgdufisdugfusdg";
a.match(/<a [^>]*href\s*=\s*["'][^>]*["'][^>]*>/)
["<a onclick=alert('blablabla') href='www.hello.com' onclick=alert('blablabla') >"]
You don't correctly test for the two possible attribute value delimiters. You can use this one :
/<a [^>]*href[ ]*=[ ]*[\"']?[^>][\"']?[^>]*>/
I just changed \"|' to [\"']? (note that it's possible not to have quotes at all, hence the ?)
The character classes you use are not always appropriate and you must surround your alternation by a group (ie: (?:'|")), but you don't need it. You can try this, with the same idea:
<a (?:[^h>]+|h(?!ref))*\bhref\s*=\s*["'][^"']*["'][^>]*>
But if you want only to find a link tag, you can use <a.+?> as thg435 suggests it.
(Note that the href value is not always between quotes:
<a (?:[^h>]+|h(?!ref))*\bhref\s*=\s*(?:["'][^"']*["']|[^\s>]*)[^>]*>
(or to be sure to have the same quotes)
<a (?:[^h>]+|h(?!ref))*\bhref\s*=\s*(?:(["'])(?:\\\1|[^"']+|(?!\1)["'])*\1|[^\s>]*)[^>]*>

Categories

Resources