Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Javascript problem

Javascript problem

Scheduled Pinned Locked Moved Web Development
questionjavascripthtmlsecuritytools
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fakefur
    wrote on last edited by
    #1

    I am trying to pop up a window from a link on a web page using the following code: [head] [script etc etc] function popup(url) { window.open(url,'title','300,300'); } [/script] [/head] [body] [a href='javascript:popup('someurl.html')']blahblah[/a] [/body] [edit] The colon between javascript and popup is not showing up on this page but it is in the code [/edit] I have only shown the reqd bits so please don't tell me I missed out parts of the page :) Now this works fine except if I use it in an IFrame on IE. On FF etc it works just as I would expect. Does anybody have a clue if this is a security feature of IE? Or what is wrong? Thanks

    G 1 Reply Last reply
    0
    • F fakefur

      I am trying to pop up a window from a link on a web page using the following code: [head] [script etc etc] function popup(url) { window.open(url,'title','300,300'); } [/script] [/head] [body] [a href='javascript:popup('someurl.html')']blahblah[/a] [/body] [edit] The colon between javascript and popup is not showing up on this page but it is in the code [/edit] I have only shown the reqd bits so please don't tell me I missed out parts of the page :) Now this works fine except if I use it in an IFrame on IE. On FF etc it works just as I would expect. Does anybody have a clue if this is a security feature of IE? Or what is wrong? Thanks

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The problem is that you use the same delimiter for html attributes and javascript strings. The browser thinks that the attribute ends where you think that the string starts. To the browser, it's only this that makes sense of your anchor tag: [a href='javascript:popup(']blahblah[/a] This will of course cause an error. If you had error messages enabled in your browser, you would get the error in a popup. Now it only shows up in the status bar. Use quotes for html attributes and apostrophes for javascript strings: [a href="javascript:popup('someurl.html');"]blahblah[/a] --- b { font-weight: normal; }

      F 1 Reply Last reply
      0
      • G Guffa

        The problem is that you use the same delimiter for html attributes and javascript strings. The browser thinks that the attribute ends where you think that the string starts. To the browser, it's only this that makes sense of your anchor tag: [a href='javascript:popup(']blahblah[/a] This will of course cause an error. If you had error messages enabled in your browser, you would get the error in a popup. Now it only shows up in the status bar. Use quotes for html attributes and apostrophes for javascript strings: [a href="javascript:popup('someurl.html');"]blahblah[/a] --- b { font-weight: normal; }

        F Offline
        F Offline
        fakefur
        wrote on last edited by
        #3

        Thanks but that was my fault. No the delimeters aren't the same. I just typed them this way in the example code I posted. Sorry.

        G 1 Reply Last reply
        0
        • F fakefur

          Thanks but that was my fault. No the delimeters aren't the same. I just typed them this way in the example code I posted. Sorry.

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Well, you get assistance on the code you show. If you don't show the code you use, you can't get help with it. If you need to shorten the code, make sure that the example still shows the faulty behaviour that you need to fix. --- b { font-weight: normal; }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups