Diagnosing an href value being directed to another value - javascript

I'm working on site (not designed by myself) and have run into an issue I'm not able to diagnose easily.
I have a link being generated for an author's social media profiles as such:
AuthorHandle
This is correct but when this link is clicked, there is a JQuery script (I'm assuming) running somewhere that is changing the href value to the following:
https://www.sitedomain.com/https://twitter.com/authorhandle
How would one go about running down which script was responsible for this using the Chrome DevTools?
This is obviously throwing a lot of annoying 404 errors and also not allowing site visitors to find an author's twitter page.

Sounds like Rory McCrossan's comment helped. I'll document it for anyone else in the same boat.
Right-click the element and select Inspect. Then open the Event Listeners pane and expand the click section. This shows you all of the listeners that are registered for this element's click event.

Related

Facebook moderation link doesn't show when using hash in data-href URL

I am using Facebook comments in my website. My problem is that I don't get to see the moderation tool. I see it when the code is embedded within the page when it loads. In my case, I load the comment section dynamically, inserting the comment div into another div and running FB.XFBML.parse();.
Note: I am using hash in the URL for the data-href.
I do see the Facebook comments plugin and I can write comments, but the moderation tool is not visible.
Any ideas how to make the moderation tool visible also when dynamically rendering Facebook comments plugin?
Update: I've also found out that the moderation link doesn't show up when I have the data-href in place, even if I embed the widget inline and load it when the page loads. I use a link that the code runs on and with App Id assigned correctly. I did scrapped the page using Facebook tool and found no issue.
This code doesn't show the moderation link:
<div class="fb-comments" data-href="https://example.com/" data-numposts="5"></div>
Update 2: I removed the data-href from the dynamically inserted widget div and it still doesn't work.
Update 3: I removed the hash from the data-href URL in the inline code and it shows the moderation link with the data-href. Leads me to believe that the hash might cause an issue here.
Update 4: Moderation appears when dynamically loading the widget, but only when there is not hash in the URL. So the hash seems to be the issue. Need to ind way to solve this.
The problem with using a hash is that Facebook doesn't even recognize this Comments box as part of the one that is assigned to my website. I asked someone to post a link (which should be moderated) none of the comments, nor the one with the link appeared in the online moderation panel on Facebook.

How to Disable a specific link using html or javascript

I am using a Gchat voice and video chat script. link to my website
The problem is that someone login in my chatroom and he use this flash link to crash users browser.
when he login all of us get disconnected and we have a blank black page at that time.
He must be using src="http://best-hosting.cu.cc/c/banner3-www-facebook-skype-net-com.swf" or iframe of that link somewhere when he is logging in.
Please help me. How can I disable that flash thing not to load in all users browsers
I get his links detect using ads block plus extension in firefox when he login with that flash link thing. when i block his link in ads block plus then i do not get disconnect but the other users who dont have ads block plus still get disconnect from website and have a blank black page.
Please suggest me something that will solve my problem.
You could try the accepted answer here: Find text and remove it jquery
Use it to find a string within the text and remove the entire thing.
I'd personally do: $('.className').contains('.swf').remove();​
Where className would be the class for links, or you could just do it for the <a> tag in general
EDIT: That being said, I have no idea what Gchat is, and whether or not this would be possible with it. If it is something hosted on your site it should work, but if it is embedded and hosted elsewhere, I'm not quite sure, worth a try though.

Website keeps causing a postback when clicking a # link

I think my issue is simple but I can't seem to figure out what I've done to screw things up but...
I can't do simple page postbacks without the page fully reloading for some unknown reason on my website..
EXAMPLE: I have an ANCHOR created called
<a id="multi" href="#"></a>
I can't call this link from within the page without it completely reloading the page. This is causing other serious issues such as me pulling up my website on my Android phone.. the Menu itself compresses completely fine, but when you click on the menu it actually forces the page to reload like its doing a postback or something when its not suppose to.
Same thing with my Chat Widget i have on my website on the bottom right corner... it uses javascript and has it pointed to "http://www.website.com/#" so that nothing is suppose to happen so it can load the window after its received a click, but something is causing my site to actually do a post and its trying to access that as an actual website.
Anyone have any idea what could be causing this? I've tried even completely deleting and removing all my javascript and CSS references and everything what am i missing?
The # should only be making the page jump up. However, there'll be instances where:
Check if # is still on that link
There are times where some script removes the # and make that link point somewhere else. If you're on Chrome, you can inspect the link by right-clicking on it and inspecting it (other browsers should also have this too). Check if # is still the href.
Check for click handlers
There are also times when a handler is attached to links (I have a co-developer that did this once) and introduced too much magic to the page. Inspect the element and on the Elements tab of the inspector, there should be a tab called Event Listeners. Check for click handlers and inspect that. The harder thing to catch are delegated event handlers, so check for the ancestors as well.
Overlooking the obvious
You might have missed the #
You might be editing old code
You might be editing another file (always happens)
Clean the cache or debug in incognito or another browser profile which you can openly clear the cache.

Code Mirror only displays after a user clicks on it when integrated into a Bootstrap tab

I am having an issue with integrating Code Mirror into a Bootstrap tab.
The problem is that because the Bootstrap tab is not set to active, code mirror will only display the content if the user clicks on it.
I have thoroughly searched a solution for the problem but have not found anything that works (possibly due to my knowledge about JavaScript not being very good). I have tried things like telling codemirror to refresh, but it doesn't solve the problem.
Calling .refresh() on the editor is what is needed here. You just have to make sure you do it after the editor actually becomes visible. I am not sure how to do this with Bootstrap tabs, but I'm sure there is some way to listen to tab change events.

waitForKeyElements(); - Stop a script firing on a popup in Chrome Extension?

This question is a follow-on to another question which needed asking and warranted a new post, so excuse me if I refer to things which may not be clear without reading the other question.
When using the utility waitForKeyElements() I'm facing an issue in which a div is included inside a small popup contained within the same URL. My extension is currently running on the Twitter site, and my intention is that a div contained on the profile pages (e.g. http://twitter.com/todayshow) gets moved above another div on the page. I'm doing this via waitForKeyElements() because of some loading issues which are resolved by using this utility.
However, on a profile page you can click a link to another users name which pops up a small window (inside the same window/tab, on the same URL) showing some info about them and a few previous tweets. The issue here is that the same div appears on this popup and is then moved to the main page behind the popup window, where it shouldn't be. On a profile page, this can be stopped by plugging in the false parameter to waitForKeyElements(), however on a non-profile page it is still possible to activate this popup which is then moving onto the main page, as the div I wish to move it above on a profile page still exists here, causing clear issues.
I'm wondering if there's a way around this, as bugs in Chrome have stopped me from excluding these pages. So far (just brainstorming) I'm thinking:
on a page where the div doesn't exist to begin with, create an empty one meaning false will handle the issue.
somehow stop the script from firing on a given URL, although due to the way Twitter works this would have to monitor OnClick() and the page URL (I think) which I'm unsure how to do.
stop running when the popup appears, but I have almost no idea where to start with that.
Any help is appreciated. Any necessary code related to this question can be found in the first two links, and the issue I'm facing can be seen by a quick visit to Twitter.
EDIT: When plugging in the false param it works when going directly to profiles via the URL bar, if you're on a profile and use a link to get to a profile, the script isn't inserted and my extension fails. So this would need resolving too, or an alternative method altogether.
I had a brainwave that I could use insertAfter() to insert the <div> I was originally moving in front of, after the <div> I was originally moving. This <div> is not present on the popup, which means that nothing is moved onto the back page when it shouldn't be.
In regards to the previous question, my code is now simply:
waitForKeyElements (
"jQuery selector for div(s) you want to move", // Opposite to what it was.
moveSelectDivs
);
function moveSelectDivs (jNode) {
jNode.insertAfter ("APPROPRIATE JQUERY SELECTOR"); // Again, the opposite.
}
This solves the issue I was having and my extension is now working just fine, however I will leave this question posted in case anybody comes back to it in future.

Categories

Resources