www.webdeveloper.com
Results 1 to 4 of 4

Thread: Dumb noob

  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Dumb noob

    First off, Hi all. I've recently moved to PHP after a few months on C#, and I feel like I'm right back in year 1 at school. I'm working my way through a few tutes, and one of them has a (kind of) 'now it's your turn' at the end...

    On the whole I've been doing OK, but one of the exercises wants me to change an 'open browser' window command to a simple link-to-page. I understand the principle but the syntax is killing me.

    I haven't just come here to cheat, I've spent hours looking at various docs and guides, but I can't seem to crack this basic problem.

    The current code is:

    Code:
    $eventwin = 'onclick="window.open(\'index.php?option=someurl&id='.$item->id.'\', \'win2\', \'width=800,height=400,top=100,left=100,scrollbars=1\')" ';
    I'd ideally like to create the link using 'onclick' rather than use a standard link, can anyone help? Please?

    M

  2. #2
    Join Date
    Jul 2013
    Posts
    350
    Separate your js from your html with a function call. Let the function set all the parms and execute the window.open call. Much easier to write and to understand afterwards. Just put the onclick clause in your html tag, ie:

    Code:
    echo "<input type='button' onclick='openWindow(\"$id\")' value='xxxxx'>";
    Write your javascript function as 'openWindow(my_id)'

  3. #3
    Join Date
    Sep 2013
    Posts
    221
    Ideally you can do this:

    <a href="javascriptlessDestination.html" onclick="myJSFunc(); return false;">Link text</a>

    or the different approach is given below,you can try it out and see if it help you to solve your problem:

    <style type="text/css">
    .jsAction {
    cursor: pointer;
    color: #00f;
    text-decoration: underline;
    }
    </style>

    <p>I want to call a JavaScript function <span class="jsAction" onclick="callFunction();">here</span>.</p>

    Hope this helps.
    strad solutionswww.stradsolutions.com

  4. #4
    Join Date
    Dec 2013
    Location
    Carlisle, Cumbria, United Kingdom
    Posts
    2
    Hi,

    I know this might be wrong, but from what you are describing are they not asking for just a straight Link (e.g. <a href="http://whatever.com">Link Text</a> rather than using javascript to open a new browser popup window?

    Rob

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles