Comments (11)
Hey Samuel. Can you describe the problem you're having in more detail?
What do you mean that Internet Explorer imminently creates an html link when you type one? Where are you typing in text that causes IE to automatically link things? (text field / text area? rich text editor? etc)
from autolinker.js.
Thanks for your quick reply!
Administrators on my website are able to edit the text on some pages. I'm doing this with content editable div's, and I safe the data to my database with javascript. I am applying autolink to the data just before I safe it to the database, inside the database the links are already autolinked.
I tested it in some more browsers, and it works very well with them all, exept for Safari and Internet Explorer.
from autolinker.js.
Dear gregjacobs,
This still is a problem for me and it still doesn't work. Could you please try to look into this problem?
from autolinker.js.
Hey, sorry dude, do need some more info. Can you paste what your text looks like before it is sent to Autolinker, and what it looks like after?
Would be useful to see the input text from Chrome/Firefox vs. Safari/Internet Explorer too.
from autolinker.js.
Hey,
Thanks for responding again!
Here are screenshots from all my tests. AutoLink seems to work perfectly in Safari now, too. No idea why, but i think Safari had a update which changed the behavior.
Google Chrome - before applying AutoLink:
Google Chrome - after applying AutoLink:
Mozilla Firefox - before applying AutoLink:
Mozilla Firefox - after applying AutoLink:
Opera - before applying AutoLink:
Opera - after applying AutoLink:
Safari - before applying AutoLink:
Safari - after applying AutoLink:
Internet Explorer - before applying AutoLink (it's already a link):
Internet Explorer - after applying AutoLink (AutoLink didn't do anything because it was already a link):
As it's only Internet Explorer that is not working, it is not so much of a problem for me anymore. I hate Internet Explorer anyway :). Would of course be nice if you found a way to fix it, but for me there is not so much of a hurry anymore.
Thanks for your help!
from autolinker.js.
Ah, ok, now I'm understanding. So Internet Explorer automatically creates the links for you from the content editable field, and therefore Autolinker is ignoring them.
What you might try doing is removing the IE-generated anchor tags using your browser's DOM before running Autolinker on it. Are you using any libraries? Using jQuery to unwrap the href
s from the generated <a>
tags would make this pretty straightforward. Something like this should do the trick:
var $contentEl = $( '#elementWithContent' );
// Find all anchor tags within the content, and replace them with just their href's,
// in preparation to be autolinked using Autolinker's settings
$contentEl.find( 'a' ).each( function( i, elem ) {
$( elem ).replaceWith( elem.href );
} );
var autolinkedHtml = Autolinker.link( $contentEl.html() );
If you're not using jQuery (and are having trouble), let me know and I'll come up with something else :)
from autolinker.js.
Thanks for your great help!
I am using jQuery.
But I'm really struggling to make this work. It keeps saying 'undefined is not a function' referring to this row:
div_content.find( 'a' ).each...
As you can see, I used my own variable which has the html content from the DIV. I don't know if this causes any problems (pretty new to jQuery :)) but I can't find out why it would be a problem.
Anything you can think of I might me doing wrong here?
Verzonden vanaf mijn Samsung Galaxy smartphone.
-------- Oorspronkelijk bericht --------
Van: Gregory Jacobs [email protected]
Datum:18-11-2014 02:31 (GMT+01:00)
Aan: "gregjacobs/Autolinker.js" [email protected]
Cc: samuelvisser [email protected]
Onderwerp: Re: [Autolinker.js] Autolink doesn't work in Safari and Internet
Explorer (#61)
Ah, ok, now I'm understanding. So Internet Explorer automatically creates the links for you from the content editable field, and therefore Autolinker is ignoring them.
What you might try doing is removing the IE-generated anchor tags using your browser's DOM before running Autolinker on it. Are you using any libraries? Using jQuery to unwrap the hrefs from the generated tags would make this pretty straightforward. Something like this should do the trick:
var
// Find all anchor tags within the content, and replace them with just their href's,
// in preparation to be autolinked using Autolinker's settings
$contentEl.find( 'a' ).each( function( i, elem ) {
$( elem ).replaceWith( elem.href );
} );
var autolinkedHtml = Autolinker.link( $contentEl.html() );
If you're not using jQuery (and are having trouble :)), let me know and I'll come up with something else.
—
Reply to this email directly or view it on GitHub.
from autolinker.js.
Is div_content
a jQuery object, or a reference to a DOM node?
If div_content
is a reference to a DOM node, then you need to turn it into a jQuery object using:
$( div_content ).find( 'a' ).each( ...
from autolinker.js.
Hey, hope you got this solved. Closing this ticket out for now. Feel free to continue to comment though if you have more questions!
from autolinker.js.
Sorry for the late answer, as it now also works on Safari this is not too high on my priority list anymore :)
But i still just can't make this work. I searched on the internet for a long time on how to delete all href attributes from a string, but i just can't find anything.
The part of the code with everything that happens before autolink is being used:
var div_inhoud = $("#editedText").html();
//Probleem met html code oplossen:
div_inhoud = div_inhoud.replace(/</g, '<');
div_inhoud = div_inhoud.replace(/>/g, '>');
div_inhoud = div_inhoud.replace(/ /g, ' ');
// Find all anchor tags within the content, and replace them with just their href's,
// in preparation to be autolinked using Autolinker's settings
div_inhoud.find( 'a' ).each( function( i, elem ) {
$( elem ).replaceWith( elem.href );
} );
//Links op pagina omvormen naar html links:
div_inhoud = Autolinker.link( div_inhoud );
In Chrome, the console gives the error:
Uncaught TypeError: undefined is not a function
I really don't know what i'm doing wrong.
I tried using your $( div_inhoud ) solution, but then Chrome gives this error:
Uncaught Error: Syntax error, unrecognized expression: Hello,
Don't know how to show code in a proper way on GitHub :) But it gives the string with the page content which i'm trying to save to my database. After the page content it gives the errors you can see.
from autolinker.js.
Ok, so I think I see the problem. You're working with the HTML string rather than the DOM tree structure.
I think you want something like this instead:
var div_inhoud = $("#editedText"); // note: no call to `.html()` here
// Find all anchor tags within the content, and replace them with just their href's,
// in preparation to be autolinked using Autolinker's settings
div_inhoud.find( 'a' ).each( function( i, elem ) {
$( elem ).replaceWith( elem.href );
} );
// Links op pagina omvormen naar html links:
var htmlToSaveToDatabase = Autolinker.link( div_inhoud.html() );
// Update the HTML of the element on the page with the newly-autolinked HTML
div_inhoud.html( htmlToSaveToDatabase );
I removed the replace()
calls, and named the var htmlToSaveToDatabase
for what you want to send to your DB. The last line updates the HTML on the page with the newly-autolinked html. Give that a try and let me know.
Otherwise, do you have a place where I can see the full code and page that you're editing? That would give me some more context.
from autolinker.js.
Related Issues (20)
- 3 seconds to parse link in safari HOT 7
- Request: Add taiwanese style phone number format
- URL with multiple email addresses in query string is not linked correctly
- Autolinker vulnerable to RTLO URL spoofing attacks HOT 26
- Bug: getUrl method not working correctly for links in markdown formats HOT 1
- doc/release v3.16.0 changelog missing HOT 1
- urls.wwwMatches usecase HOT 4
- Links with `¬` in query string are broken
- encoded email address is split
- Wrong result when parsing CJK(中文/日文/韩文) char followed by colon HOT 1
- Failed to parse source map HOT 2
- Add support for YouTube hashtags HOT 1
- Add support for YouTube mentions HOT 1
- Url with protocol prefixed with emoji being incorrectly parsed HOT 1
- Help to create Markdown Link Matcher
- Enable `inlineSources`
- URL as value in key-value pair parsed only partially (and incorrectly)
- [Tiktok mentions] - parsing does not match tiktok mention behaviour HOT 2
- Detection If a Persian word is attached before the link
- Help fix
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autolinker.js.