Download & Extend

IE7 outputs the full URL

Project:Node Picker
Version:6.x-1.0-alpha4
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

When adding links with IE 7 the complete URL is added to the href. So instead of /node/123 it will produce http://example.com/node/123. Because my client switches between domainnames internally and they use IE7 (I know it’s scary ;-) ) this is quite a problem.

Comments

#1

Status:active» needs review

When accessing the href DOM property of an A element in IE, it will return the absolute path to the url. The same is true for getAttribute() in IE7 and lower (since getAttribute was broken until IE8).

More info in the first answer of this post: JQuery Not Parsing Properly attr(“href”) in IE

Therefore, the solution would make the following changes to the file "/nodepicker/plugins/nodepicker/nodepicker.js"

  /**
   * Replace links with [nodepicker] tags in content upon detaching editor.
   */
  detach: function(content, settings, instanceId) {
    var $content = $('<div>' + content + '</div>'); // No .outerHTML() in jQuery :(
    $('a.nodepicker-link', $content).each(function(node) {
      var $self = $(this);
      var base = window.location.href.substring(0, window.location.href.lastIndexOf("/") + 1);
      var href = $self.attr("href").replace(base, "");
      var inlineTag = '[nodepicker==' + href + '==' + encodeURIComponent($self.attr("title")) + '==' + encodeURIComponent($self.text()) + ']';
      $(this).replaceWith(inlineTag);
    });
    return $content.html();
  }

#2

Also have to make the following changes to the file "/nodepicker/js/nodepicker.js":

  // Add on click function for link select.
  $("a.nodepicker-insert").click(function(){
    $self = $(this);
    var base = window.location.href.substring(0, window.location.href.lastIndexOf("/") + 1);
    var href = $self.attr("href").replace(base, "");
    if(parent.Drupal.settings.basePath.length > 1) {
      href = href.replace(parent.Drupal.settings.basePath, '');
    }
    nodepicker_insert(href, $self.attr("title"));
    return false;
  });
nobody click here