SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Error: missing name after . operator

    JavaScript isn't my strong suit... I've tried writing this line 4 different ways, always getting the same error. How can I rewrite all the URLs inside an iframe to call a JavaScript function with the URL as an argument instead of go to their original destination?

    Code:
    var clicks = [];
    
    function markMeUp(arr) {
    	
    	clicks = arr;
    	frame = document.getElementById('overlay_frame');
    	
    	var linkList;
    	for (var i = 0; i < frame.contentDocument.links.length; i++) {
    		link = frame.contentDocument.links[i];
    		if (link.href.indexOf('#', 0) > 0) {
    			link.href = link.href.substring(0, link.href.indexOf('#', 0));
    		}
    		iconify(frame, link);
    	}
    	
    	for (var i = 0; i < frame.contentDocument.links.length; i++) {
    		var tmp = frame.contentDocument.links[i].href;
    		frame.contentDocument.links[i].href = "parent.overlay('" . escape(tmp) . "')";
    	}
    
    }
    Code:
    Error: missing name after . operator
    Source File: http://localhost/js/overlay.js
    Line: 19, Column: 75
    Source Code:
    frame.contentDocument.links[i].href = "parent.overlay('" . escape(tmp) . "')";

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    "parent.overlay('" . escape(tmp) . "')";

    should be

    "parent.overlay('" + escape(tmp) + "')";
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Gah, how stupid of me. Thanks.

  4. #4
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    813
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you must have a lot php influence

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SimplyFu View Post
    you must have a lot php influence
    Heck, that's just the beginning of it. I'm juggling 5 or 6 languages a day. C# and SQL Server's brand of SQL at work, some JScript there, come home and work on websites in both PHP and Perl, MySQL's version of SQL for those, and a Java app occasionally I'm trying to finish.

  6. #6
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for this post. I did the same thing a second ago, using the Perl/PHP concat operator instead of the '+' in JS.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •